forked from careerist-qa/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw2
More file actions
39 lines (32 loc) · 1.18 KB
/
hw2
File metadata and controls
39 lines (32 loc) · 1.18 KB
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
32
33
34
35
36
37
38
39
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Set up Chrome in Incognito mode
chrome_options = Options()
chrome_options.add_argument("--incognito")
driver = webdriver.Chrome(options=chrome_options)
try:
# Step 1: Open Target homepage
driver.get("https://www.target.com/")
# Step 2
sign_in_menu = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//span[text()='Sign in']"))
)
sign_in_menu.click()
# Step 3
sign_in_link = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//a[@data-test='accountNav-signIn']"))
)
sign_in_link.click()
# Step 4
WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.XPATH, "//h1[contains(text(), 'Sign into your Target account')]"))
)
print("✅ Sign-in header is visible")
# Verify SignIn
sign_in_button = driver.find_element(By.ID, "login")
print("✅ Sign-in button is located")
finally:
driver.quit()