forked from careerist-qa/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmazon_sample_script.py
More file actions
26 lines (19 loc) · 873 Bytes
/
Amazon_sample_script.py
File metadata and controls
26 lines (19 loc) · 873 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
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
# create a new Chrome browser instance
service = Service(executable_path='<provide your absolute path>')
driver = webdriver.Chrome(service=service)
driver.maximize_window()
driver.get('https://www.amazon.com/')
# Input search text
driver.find_element(By.ID, 'twotabsearchtextbox').send_keys('table')
# Click on search btn
driver.find_element(By.ID, 'nav-search-submit-button').click()
expected_result = '"table"'
actual_result = driver.find_element(By.XPATH, "//span[@class='a-color-state a-text-bold']").text
assert expected_result == actual_result, f'Expected {expected_result} did not match actual {actual_result}'
print('Test case passed')
driver.quit()