forked from careerist-qa/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw11
More file actions
66 lines (50 loc) · 2.04 KB
/
hw11
File metadata and controls
66 lines (50 loc) · 2.04 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://help.target.com/help")
try:
# Assume there's a search bar instead of a traditional dropdown
search_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "searchTerm")) # Adjust ID if needed
)
search_input.send_keys("Returns")
search_button = driver.find_element(By.ID, "searchSubmit") # Adjust if needed
search_button.click()
WebDriverWait(driver, 10).until(
EC.url_contains("childcat=Returns")
)
assert "Returns" in driver.title or "Returns" in driver.page_source
print("Help page search test passed.")
finally:
driver.quit()
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://www.target.com/account/signin")
try:
# Step 1: Enter valid email and continue
email_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "username"))
)
email_input.send_keys("your_valid_email@example.com")
continue_button = driver.find_element(By.ID, "continue")
continue_button.click()
# Step 2: Enter incorrect password
password_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "password"))
)
password_input.send_keys("wrongpassword123")
sign_in_button = driver.find_element(By.ID, "login")
sign_in_button.click()
# Step 3: Check for error message
error_msg = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.CLASS_NAME, "styles__ErrorMessage-sc-1tby3k4-2")) # Update if needed
)
assert "incorrect" in error_msg.text.lower()
print("Sign-in error test passed.")
finally:
driver.quit()