From aa5b1f0ee357882acc56fc82928a2975d8b02f97 Mon Sep 17 00:00:00 2001 From: majesticj Date: Fri, 11 Apr 2025 17:39:58 -0500 Subject: [PATCH] hw2 --- hw2 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 hw2 diff --git a/hw2 b/hw2 new file mode 100644 index 000000000..1980c05b5 --- /dev/null +++ b/hw2 @@ -0,0 +1,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 + 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 button is present + sign_in_button = driver.find_element(By.ID, "login") + print(" Sign-in button is located") + +finally: + driver.quit()