Grabbing Locator Index Automatically

断了今生、忘了曾经 提交于 2019-12-10 12:16:12

问题


I'm going to try to explain this the best I can without making it too complicated. Currently I have a program which automatically grabs an element's locator (id, css, xpath) when I click on an element on a page.

The problem is, the element's css (ID, class name, etc) that I am grabbing is not unique (I cannot change the website)

I know in chrome, when I type $$('#test'), it will bring me a list of locators with ID 'test'. From there I know I could manually find the index of the element. However I want to do this automatically.

My application is essentially a recorder which captures the element locators. I am capturing the element event through selenium webdriver, but I am unable to get the index of that. I know this is a little confusing, but any help would be greatly appreciated.

By the way, I cannot use xpath.

Thanks.

来源:https://stackoverflow.com/questions/41946684/grabbing-locator-index-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!