forked from careerist-qa/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomework2.py
More file actions
42 lines (24 loc) · 961 Bytes
/
Homework2.py
File metadata and controls
42 lines (24 loc) · 961 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
32
33
34
35
36
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.fedcm import account
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')
driver.find_element(By.XPATH,"//input[@id='search']").send_keys('toilet tissue')
sleep(5)
#search:
driver.find_element(By.XPATH,"//span[contains(.,'Account')]").click()
driver.find_element(By.XPATH, "//button[@data-test='accountNav-signIn']").click()
sleep(5)
driver.find_element(By.XPATH,"//h1[contains(.,'Sign in or create account')]")
driver.find_element(By.ID,"login")
time.sleep(20)