0
List<String> allLinks = driver.findElements(By.tagName("span"));
System.out.println("Links count is: "+allLinks.size());
for(WebElement link : allLinks)
System.out.println(link.getText());

Please let me know how can i read all elements text value dynamically from dissimilar tags present in the screen

sample HTML code

<span id="Lbl_Code" class="cus-lbl-on">Code</span>

<label for="Chk_OpenCalls">Team Member self assignment of open calls</label>
<font color="red">*</font>
<input type="submit" name="but_save" value="Save" onclick="return 
   teamvalidate();" id="but_save" class="btn cus-btn-save">
  • All elements or all links? – Alexey R. Apr 24 '18 at 5:12
  • I want to retrieve all elements text value (Label name)which is belongs to dissimilar tags present in the UI screen. – Vel Guru Apr 26 '18 at 4:09
  • I have also attached HTML code for more clarifications: sample HTML code <!--snippet--> <span id="Lbl_Code" class="cus-lbl-on">Code</span> <label for="Chk_OpenCalls">Team Member self assignment of open calls</label> <font color="red">*</font> <input type="submit" name="but_save" value="Save" onclick="return teamvalidate();" id="but_save" class="btn cus-btn-save"> <!--snippet--> – Vel Guru Apr 26 '18 at 4:22
0

I have tried the below solution its working as expected.

//*[string-length(normalize-space(text())) > 0]

text() Selects all strings

normalize-space(text()) Selects all strings removing their spaces

string-length(normalize-space(text())) > 0 Selects all texts not empty strings

//*[CONDICTION] searching in all document based in a condiction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.