step to reach that page. url:http://automationpractice.com/
- search product.
- hover a product and click Quick view
- Click Add to cart
- Try to interact to any element from light box. // there is no iframe.
step to reach that page. url:http://automationpractice.com/
Using Selenide this, a little ugly, code working for me:
@Test
public void addItemToCart() {
open("http://automationpractice.com/");
$(By.xpath("//*[@id=\"homefeatured\"]/li[1]/div/div[1]/div")).hover();
$(By.xpath("//*[@id=\"homefeatured\"]/li[1]/div/div[1]/div/a[2]/span")).click();
switchTo().frame($x("//*[@id=\"index\"]/div[2]/div/div/div/div/iframe"));
$x("//*[@id=\"add_to_cart\"]/button").shouldBe(visible, Duration.ofSeconds(10));
$x("//*[@id=\"add_to_cart\"]/button").click();
$x("//*[@id=\"layer_cart_product_price\"]").shouldBe(visible, Duration.ofSeconds(10));
assert $x("//*[@id=\"layer_cart_product_price\"]").text().equals("$16.51");
$x("//*[@id=\"layer_cart\"]/div[1]/div[2]/div[4]/a/span").click();
assert $("#cart_title").text().equals("Shopping-cart summary");
}
As I said a problem was in iframe.