2

Can someone give a coding example of how to use this Selenium command?

getElementIndex()

More info: https://selenium.dev/selenium/docs/api/java/com/thoughtworks/selenium/webdriven/commands/GetElementIndex.html.

If it has been deprecated, how would I know?

In other words, this code below is throwing an error as though it has been deprecated:

driver().findElement(By.id("id_value")).getElementIndex();
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
JohnP2
  • 1,899
  • 19
  • 17

2 Answers2

2

To answer my own question: The above code is for the HTML Selenium recorder (in Selenese), and not for the Java version of Selenium. Someone else has already offered a java equivalent here: https://stackoverflow.com/a/31289125/1691651

JohnP2
  • 1,899
  • 19
  • 17
1

GetElementIndex

GetElementIndex() class returns the index of an element. It is a part of com.thoughtworks.selenium package and the constructor is as follows:

GetElementIndex(ElementFinder finder, JavascriptLibrary js) 

But Selenium's client is based on org.openqa.selenium package.


Conclusion

There is no equivalent method of com.thoughtworks.selenium's GetElementIndex() in Selenium's Java client. However, you can always create your own customized methods.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352