0

Question Statement : I am trying to get the value of span tag on a webpage. * there are multiple span tags on that web page, out of which I need 4.

<span class="t">TEST VALUE</span>
  • Please provide some more html and what does it mean 4. would you like to have 4th element text or out of 4 elements you would like to have the 4th element text?? – KunduK Sep 16 '19 at 19:43

1 Answers1

0

If the spans have unique classes, or all 4 (and no other) spans have the class "t", than you can retrieve it by class. Otherwise, you can always retrieve them using xpath (as long as the page dom doesn't change/generate 'randomly'). However, if you have access to the page code, I would recommend instead adding a unique id to each of the spans and than retrieving them by ID.

Depending on your code and version of selenium, you'll want to look at driver.findElement & ExpectedConditions

M. Broz
  • 704
  • 4
  • 11