Answer the question
In order to leave comments, you need to log in
How to work with multiple elements in Selenium?
For example, there is a search bar (only available on the main page)
I find the element:
WebElement searchForm = selenium.findElement(By.xpath("//input[@name='searchable']"));
I pass the required request and send:searchForm.sendKeys("Orico technology");
searchForm.submit();
searchForm.sendKeys("Vasya aloo");
searchForm.submit();
In this case, an Exception will pop up because this element is not on the current page (search is available only from the main one) . Answer the question
In order to leave comments, you need to log in
Little information was provided ... but you can do the following:
use a loop ... For example, take an array String{}
or LIst<String>
And then something like this code:
String [] keys = {"key1","key2","key3"};
for (Sting key : keys) {
WebElement searchForm = selenium.findElement(By.xpath("//input[@name='searchable']"));
searchForm.sendKeys(key);
searchForm.submit();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question