forked from careerist-qa/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcart.feature
More file actions
23 lines (16 loc) · 756 Bytes
/
cart.feature
File metadata and controls
23 lines (16 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from selenium.webdriver.common.by import By
from behave import given, when, then
from time import sleep
@given('Open target main page')
def open_target_main(context):
context.driver.get('https://www.target.com/')
@when('Search for tea')
def search_product(context):
context.driver.find_element(By.ID, 'search').send_keys('tea')
context.driver.find_element(By.XPATH, "//button[@data-test='@web/Search/SearchButton']").click()
sleep(6)
@then('Verify correct search results show')
def verify_search_results(context):
actual_text = context.driver.find_element(By.XPATH, "//div[@data-test='lp-resultsCount']").text
expected_text = 'tea'
assert expected_text in actual_text, f'Error. Text {expected_text} not in {actual_text}'