Reputation: 1
When we create Page(Class) for some WebElement(driver.findElements(By.xpath("//h4[@class='card-title']")) and this element is a part of a List do we change only that part im main testcase(after creating method for it) and the remaining is the same or not? example:
List<WebElement> products =driver.findElements(By.xpath("//h4[@class='card-title']"));
for(int i=0;i<products.size();i++)
{
String name=products.get(i).getText();
if(name.contains("Samsung"))
{
driver.findElements(By.xpath("//div[@class='card-footer']/button")).get(i).click();
break;
}
}
I am not sure about that and that's the reason for question
Upvotes: 0
Views: 76
Reputation: 11
With the given limited data in the question, it is pretty unclear but as far as my understanding goes it not the same piece of code. We should segregate the page classes and test cases(@test).
Upvotes: 1