Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pytest
- from selenium import webdriver
- from selenium.webdriver import ActionChains
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.select import Select
- expected_title = 'Demo Table for practicing Selenium Automation'
- base_url = 'https://www.toolsqa.com/automation-practice-table/'
- @pytest.fixture()
- def env_setup():
- global driver
- global baseUrl
- # we will use Google Chrome in this test. Specify the location of your chromedriver.exe
- driver = webdriver.Chrome("C:\\Users\\yivanov\\Downloads\\chromedriver_win32_76\\chromedriver.exe")
- # wait for 10 seconds till the web page will load
- driver.implicitly_wait(10)
- # maximize browser window to full screen
- driver.maximize_window()
- yield
- # when test is done, close ALL windows of the browser
- driver.quit()
- def test_title(env_setup):
- # navigate to Amazon.com home page
- driver.get(base_url)
- # verify that website title is Amazon.com
- assert expected_title == driver.title
- actions = ActionChains(driver)
- actions.move_to_element(driver.find_element_by_id('content'))
- actions.perform()
- table = driver.find_element_by_xpath("//table[@class='tsc_table_s13']")
- rows = table.find_elements(By.TAG_NAME, "tr")
- cell = table.find_elements(By.TAG_NAME,"td")
- # for row in rows:
- # print(row.text)
- # print(rows[2].text)
- #
- # print(cell[10].text)
- # cell = rows.find_elements(By.TAG_NAME,"td")
- # print(rows[2].text)
- # print(type(rows[2]))
- cells = driver.find_elements_by_xpath("//table[@class='tsc_table_s13']//tr[3]/td")
- print(cells[0].text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement