44from selenium .webdriver .support import expected_conditions as EC
55from selenium .webdriver .common .by import By
66from selenium .common .exceptions import NoSuchElementException , TimeoutException
7+ from percy import percy_snapshot
78
89# Define a pytest fixture for the WebDriver setup and teardown
910@pytest .fixture (params = ["chrome" , "firefox" , "safari" ], scope = "function" )
@@ -29,7 +30,7 @@ def test_add_to_cart(driver):
2930
3031 # Wait for the page title to contain 'StackDemo'
3132 WebDriverWait (driver , 30 ).until (EC .title_contains ('StackDemo' ))
32- PercySDK . screenshot (driver , " page1" )
33+ percy_snapshot (driver , ' page1' )
3334 # Get the text of the product - iPhone 12
3435 item_on_page = WebDriverWait (driver , 10 ).until (
3536 EC .visibility_of_element_located ((By .XPATH , '//*[@id="1"]/p' ))
@@ -44,7 +45,7 @@ def test_add_to_cart(driver):
4445 WebDriverWait (driver , 30 ).until (
4546 EC .visibility_of_element_located ((By .CLASS_NAME , 'float-cart__content' ))
4647 )
47- PercySDK . screenshot (driver , " page2" )
48+ percy_snapshot (driver , ' page2' )
4849 # Get the text of the product in the cart
4950 item_in_cart = WebDriverWait (driver , 30 ).until (
5051 EC .visibility_of_element_located ((By .XPATH , '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]' ))
0 commit comments