mercredi 22 mai 2019

xPath doesn't go on to the next page

When I use below code, the website doesn't go on to the next page.

import unittest
from selenium import webdriver
import time

class ProductPurchase(unittest.TestCase):
    """
    Purchase the product on the website http://automationpractice.com/index.php
    """
    # Preconditions
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.get("http://automationpractice.com/index.php")
        self.driver.maximize_window()
    def teardown(self):
        self.driver.quit()
    # Buying a product on the website 
    def test_wrong_agreement(self):
        driver = self.webdriver
        time.sleep(2)
    #Click on "Quick view"
    quickview_btn = driver.find_element_by_xpath("/html/body/div/div[2]/div/div[2]/div/div[1]/ul[1]/li[1]/div/div[1]/div/a[2]").click()


if __name__ == '__main__':
    unittest.main(verbosity=2)

It should go on to the next page but xPath doesn't work.

Aucun commentaire:

Enregistrer un commentaire