Selenium Webdriver with Java (Angular application)
up vote
0
down vote
favorite
I have written below code for selecting mentioned values from the drop-down list.
Here I want to select only these @data-option-array-index=1,3,5,9,28,34
from the drop-down list.
I want to use kind of array or loop in which it will run for these selected values only. But I am unable to do it.
element=driver.findElement(By.xpath("//li[@class='search-field']"));
element.click();
element=driver.findElement(By.xpath("//li[@data-option-array-index='1']"));
element.click();
String text=driver.findElement(By.xpath("//li[@class='search-choice']")).getText();
System.out.println("Element text is: "+ text);
java selenium selenium-webdriver
add a comment |
up vote
0
down vote
favorite
I have written below code for selecting mentioned values from the drop-down list.
Here I want to select only these @data-option-array-index=1,3,5,9,28,34
from the drop-down list.
I want to use kind of array or loop in which it will run for these selected values only. But I am unable to do it.
element=driver.findElement(By.xpath("//li[@class='search-field']"));
element.click();
element=driver.findElement(By.xpath("//li[@data-option-array-index='1']"));
element.click();
String text=driver.findElement(By.xpath("//li[@class='search-choice']")).getText();
System.out.println("Element text is: "+ text);
java selenium selenium-webdriver
Update the question with the relevant HTML
– DebanjanB
Nov 12 at 10:17
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have written below code for selecting mentioned values from the drop-down list.
Here I want to select only these @data-option-array-index=1,3,5,9,28,34
from the drop-down list.
I want to use kind of array or loop in which it will run for these selected values only. But I am unable to do it.
element=driver.findElement(By.xpath("//li[@class='search-field']"));
element.click();
element=driver.findElement(By.xpath("//li[@data-option-array-index='1']"));
element.click();
String text=driver.findElement(By.xpath("//li[@class='search-choice']")).getText();
System.out.println("Element text is: "+ text);
java selenium selenium-webdriver
I have written below code for selecting mentioned values from the drop-down list.
Here I want to select only these @data-option-array-index=1,3,5,9,28,34
from the drop-down list.
I want to use kind of array or loop in which it will run for these selected values only. But I am unable to do it.
element=driver.findElement(By.xpath("//li[@class='search-field']"));
element.click();
element=driver.findElement(By.xpath("//li[@data-option-array-index='1']"));
element.click();
String text=driver.findElement(By.xpath("//li[@class='search-choice']")).getText();
System.out.println("Element text is: "+ text);
java selenium selenium-webdriver
java selenium selenium-webdriver
edited Nov 11 at 12:51
Jayendran
2,95631334
2,95631334
asked Nov 11 at 10:23
indu khandelwal
1
1
Update the question with the relevant HTML
– DebanjanB
Nov 12 at 10:17
add a comment |
Update the question with the relevant HTML
– DebanjanB
Nov 12 at 10:17
Update the question with the relevant HTML
– DebanjanB
Nov 12 at 10:17
Update the question with the relevant HTML
– DebanjanB
Nov 12 at 10:17
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Use findElements,
List<WebElement> choises=driver.findElements(By.xpath("//li[@class='search-choice']"));
List<String> listValues= new Arraylist<String>();
for(WebElement choise : choises)
listValues.add(choise.getText());
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Use findElements,
List<WebElement> choises=driver.findElements(By.xpath("//li[@class='search-choice']"));
List<String> listValues= new Arraylist<String>();
for(WebElement choise : choises)
listValues.add(choise.getText());
add a comment |
up vote
0
down vote
Use findElements,
List<WebElement> choises=driver.findElements(By.xpath("//li[@class='search-choice']"));
List<String> listValues= new Arraylist<String>();
for(WebElement choise : choises)
listValues.add(choise.getText());
add a comment |
up vote
0
down vote
up vote
0
down vote
Use findElements,
List<WebElement> choises=driver.findElements(By.xpath("//li[@class='search-choice']"));
List<String> listValues= new Arraylist<String>();
for(WebElement choise : choises)
listValues.add(choise.getText());
Use findElements,
List<WebElement> choises=driver.findElements(By.xpath("//li[@class='search-choice']"));
List<String> listValues= new Arraylist<String>();
for(WebElement choise : choises)
listValues.add(choise.getText());
answered Nov 11 at 11:38
Navarasu
1,8321721
1,8321721
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247799%2fselenium-webdriver-with-java-angular-application%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Update the question with the relevant HTML
– DebanjanB
Nov 12 at 10:17