forked from careerist-qa/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_script.py
More file actions
executable file
·31 lines (22 loc) · 1015 Bytes
/
sample_script.py
File metadata and controls
executable file
·31 lines (22 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from time import sleep
# get the path to the ChromeDriver executable
driver_path = ChromeDriverManager().install()
# create a new Chrome browser instance
service = Service(driver_path)
driver = webdriver.Chrome(service=service)
driver.maximize_window()
# open the url
driver.get("https://www.target.com/")
#Click SignIn button
driver.find_element(By.XPATH, "//a[@id='account']")
#Click SignIn from side navigation
driver.find_element(By.XPATH, "//a[contains(text(),'Sign in')]")
#Verify SignIn page opened:
driver.find_element(By.XPATH, "//h1[text()='Sign into your Target account']")
#SignIn button is shown (you can just use driver.find_element() to check for element’s presence, no need to assert here)
driver.find_element(By.XPATH,"//button[contains(@type,'submit') and contains(text(),'Sign in')]")
driver.quit()