i had a doubt please help me.
i wrote script List< WebElement> select =driver.findElements(By.xpath("//android.widget.TextView"));
System.out.println( select.size());
it shows value as 9.
my question is ,how to get first 3 values from the list of 9 values.
and the fetch data (like text ,numbers) of the 3 values from 9 values
Hi,
if you wanna get text from the element number 01, you can use: select.get(0).getText();
The 2nd, select.get(1).getText();
The 3rd: select.get(2).getText();
If you wanna to click on the element number 01. select.get(0).click();
I think you can get the idea.
Hopefully it helps you.
thanks for your information,
but it does not print the text from the list.
please give another suggestions
my script and output was posted.
in that i got 7 in the list ,but text contains in the list is not printed
Because you didn’t print it out!
Please use: System.out.println(select.get(i).getText());
okay friend ,i got the text.thanks for the idea.
9 (the list contains)
LYNK Money
Introducing LYNK Money
Cashless, hassle-free trips
0
Recharge Money
? 5000
? 2500
? 750
RECHARGE
i want to select or click only the below values using forloop
? 5000
? 2500
? 750
you can:
- Write a simple boolean method to select the expected element to trigger action
for ex:
String elementValue = select.get(i).getText();
if (elementValue == “? 5000” || elementValue =="? 2500" || elementValue == “? 750” ){
// Your code here to assign a boolean variable
}
thnks friend .it works for me