I have created a test that adds xyz1 , xyz2, xyz3 ....xyz(n) element , what is presented as a list on page. I need to be sure that among these names exists element titled " xyz3" (or titled different , what I will define) My idea is to build list/ array /collection that will gather all values of web element and then I need to write a method that will looking for my defined "xyz3" among these values collected in list. My web element: 
@FindBy(how = How.XPATH, using = "//div[@id='_field']")
public List <WebElement> listOfNames;
My attempts in creating a list :
LList<WebElement> myElements = createEvalTemplateLocators.getListOfNames();
boolean temp1;
for(WebElement e : myElements) {
System.out.println(e.getText() + "");
}
for(WebElement e : myElements) {
temp1 = e.getText().contains("temp1");
if (temp1==true) System.out.println("hurray temp1 is on page ");
else {System.out.println("something gone wrong with temp1");}
}
RESULT IN CONSOLE:
I am not able to create better locator- more appropiate that will not 'take' element next to it... Moreover I want to know if on the list exist 'temp1' one at least only, info message about each entity is not neccessary.... I don't have any better ideas for my test, in the future I would like to use asserts for this case..
I am beginner :( and I am learning on my own mostly, so could anybody help me with this case ?
( Greetings from Baltic Sea for All :))

Aucun commentaire:
Enregistrer un commentaire