I am trying to achieve the following:
- If a specific element exists, click it and go back to the home page.
- Otherwise, just go back to home page so the test continues on without failing
I have come up with the code below, this but it is really slow. I am not sure there is any better way to implement this? Any comments will be appreciated!!
boolean exists = driver.findElements( By.id("xxx")).size() != 0;
if (exists)
{
driver.findElement(By.id("xxx")).click();
driver.findElement(By.cssSelector("xxx")).click();
}
else
{
driver.findElement(By.cssSelector("xxx")).click();
}