问题
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