forked from careerist-qa/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamazon_search.py
More file actions
19 lines (13 loc) · 745 Bytes
/
amazon_search.py
File metadata and controls
19 lines (13 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from selenium.webdriver.common.by import By
from behave import given, when, then
@given('Open Amazon page')
def open_amazon(context):
context.driver.get('https://www.amazon.com/')
@when('Search for {search_word} on amazon')
def search_product(context, search_word):
context.driver.find_element(By.ID, 'twotabsearchtextbox').send_keys(search_word)
context.driver.find_element(By.ID, 'nav-search-submit-button').click()
@then('User sees results for {expected_result}')
def verify_search_results(context, expected_result):
actual_result = context.driver.find_element(By.XPATH, "//span[@class='a-color-state a-text-bold']").text
assert expected_result == actual_result, f'Expected {expected_result} but got {actual_result}'