From 00376870383cf691a4b2dd89db83d53365a7b77e Mon Sep 17 00:00:00 2001 From: dgilliam34 Date: Sat, 27 Sep 2025 17:20:28 -0400 Subject: [PATCH 1/3] target_test.py --- sample_script.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/sample_script.py b/sample_script.py index 3925e9462..42c3481df 100755 --- a/sample_script.py +++ b/sample_script.py @@ -4,6 +4,8 @@ from webdriver_manager.chrome import ChromeDriverManager from time import sleep +from features.steps.product_search import click_search_icon + # get the path to the ChromeDriver executable driver_path = ChromeDriverManager().install() @@ -13,21 +15,11 @@ driver.maximize_window() # open the url -driver.get('https://www.google.com/') - -# populate search field -search = driver.find_element(By.NAME, 'q') -search.clear() -search.send_keys('Car') - -# wait for 4 sec -sleep(4) - -# click search button -driver.find_element(By.NAME, 'btnK').click() +driver.get("https://www.target.com/") -# verify search results -assert 'car'.lower() in driver.current_url.lower(), f"Expected query not in {driver.current_url.lower()}" -print('Test Passed') +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") -driver.quit() From af9b8d236e86e4f43f5c60a4b6c4f7d219ed62de Mon Sep 17 00:00:00 2001 From: Davon G Date: Tue, 30 Sep 2025 11:17:40 -0400 Subject: [PATCH 2/3] Update Automated Search script --- Homework2.py | 38 ++++++++++++++++++++++++++++++++++++++ Target_Test.py | 34 ++++++++++++++++++++++++++++++++++ css_selector.py | 0 sample_script.py | 4 ++-- 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 Homework2.py create mode 100644 Target_Test.py create mode 100644 css_selector.py diff --git a/Homework2.py b/Homework2.py new file mode 100644 index 000000000..d66054405 --- /dev/null +++ b/Homework2.py @@ -0,0 +1,38 @@ +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') + +#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) + + + + + + diff --git a/Target_Test.py b/Target_Test.py new file mode 100644 index 000000000..1553e1750 --- /dev/null +++ b/Target_Test.py @@ -0,0 +1,34 @@ +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 + +from features.steps.product_search import click_search_icon + +# 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,"//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") + + + + + + + + + + diff --git a/css_selector.py b/css_selector.py new file mode 100644 index 000000000..e69de29bb diff --git a/sample_script.py b/sample_script.py index 3925e9462..0726de736 100755 --- a/sample_script.py +++ b/sample_script.py @@ -18,7 +18,7 @@ # populate search field search = driver.find_element(By.NAME, 'q') search.clear() -search.send_keys('Car') +search.send_keys('dresser') # wait for 4 sec sleep(4) @@ -27,7 +27,7 @@ driver.find_element(By.NAME, 'btnK').click() # verify search results -assert 'car'.lower() in driver.current_url.lower(), f"Expected query not in {driver.current_url.lower()}" +assert 'dressers'.lower() in driver.current_url.lower(), f"Expected query not in {driver.current_url.lower()}" print('Test Passed') driver.quit() From 466c8439254b70fbeef04880fb32e5b111a51dfa Mon Sep 17 00:00:00 2001 From: Davon G Date: Wed, 22 Oct 2025 19:52:51 -0400 Subject: [PATCH 3/3] Update automation cart & signin scripts --- Homework2.py | 4 ++++ Target_Test.py | 1 - features/__init__.py | 0 features/environment.py | 1 + features/steps/__init__.py | 0 features/steps/cart_steps.py | 30 +++++++++++++++++++++++++ features/steps/product_search.py | 32 --------------------------- features/steps/signin_steps.py | 23 +++++++++++++++++++ features/tests/__init__.py | 0 features/tests/cart.feature | 7 ++++++ features/tests/product_search.feature | 7 ------ features/tests/signin.feature | 8 +++++++ 12 files changed, 73 insertions(+), 40 deletions(-) delete mode 100755 features/__init__.py delete mode 100755 features/steps/__init__.py create mode 100644 features/steps/cart_steps.py delete mode 100755 features/steps/product_search.py create mode 100644 features/steps/signin_steps.py delete mode 100755 features/tests/__init__.py create mode 100644 features/tests/cart.feature delete mode 100755 features/tests/product_search.feature create mode 100644 features/tests/signin.feature diff --git a/Homework2.py b/Homework2.py index d66054405..a0e9f760e 100644 --- a/Homework2.py +++ b/Homework2.py @@ -18,6 +18,9 @@ # 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() @@ -29,6 +32,7 @@ + time.sleep(20) diff --git a/Target_Test.py b/Target_Test.py index 1553e1750..ea89aed26 100644 --- a/Target_Test.py +++ b/Target_Test.py @@ -4,7 +4,6 @@ from webdriver_manager.chrome import ChromeDriverManager from time import sleep -from features.steps.product_search import click_search_icon # get the path to the ChromeDriver executable driver_path = ChromeDriverManager().install() diff --git a/features/__init__.py b/features/__init__.py deleted file mode 100755 index e69de29bb..000000000 diff --git a/features/environment.py b/features/environment.py index 1275460a0..444e22d77 100755 --- a/features/environment.py +++ b/features/environment.py @@ -1,6 +1,7 @@ from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager +from behave import given,when,then def browser_init(context): diff --git a/features/steps/__init__.py b/features/steps/__init__.py deleted file mode 100755 index e69de29bb..000000000 diff --git a/features/steps/cart_steps.py b/features/steps/cart_steps.py new file mode 100644 index 000000000..439870e8c --- /dev/null +++ b/features/steps/cart_steps.py @@ -0,0 +1,30 @@ +from behave import when,given,then +from selenium import webdriver +from selenium.webdriver.common.by import By + + +from time import sleep + + +@given('Open Target page') +def open_main(context): + context.driver.get("https://www.target.com/") + + +@when('Click on add to cart icon') +def click_add_to_cart(context): + context.driver.find_element(By.CSS_SELECTOR,"#headerPrimary > a.styles_ndsLink__GUaai.styles_onLight__QKcK7.sc-7f25f5f4-1.sc-5c0d75eb-0.jaPeIi.iQmnSG > div > svg").click() + +@then('verify empty cart message') +def verify_empty_cart_message(context): + expected_text= "Your cart is empty" + actual_text= context.driver.find_element(By.XPATH,"//h1[contains(@class,'M5gHh')]").text + assert actual_text== expected_text, f"Expected:{expected_text} but got Actual:{actual_text}" + + + + + + + + diff --git a/features/steps/product_search.py b/features/steps/product_search.py deleted file mode 100755 index 4e142cb40..000000000 --- a/features/steps/product_search.py +++ /dev/null @@ -1,32 +0,0 @@ -from selenium.webdriver.common.by import By -from behave import given, when, then -from time import sleep - - -SEARCH_INPUT = (By.NAME, 'q') -SEARCH_SUBMIT = (By.NAME, 'btnK') - - -@given('Open Google page') -def open_google(context): - context.driver.get('https://www.google.com/') - - -@when('Input {search_word} into search field') -def input_search(context, search_word): - search = context.driver.find_element(*SEARCH_INPUT) - search.clear() - search.send_keys(search_word) - sleep(4) - - -@when('Click on search icon') -def click_search_icon(context): - context.driver.find_element(*SEARCH_SUBMIT).click() - sleep(1) - - -@then('Product results for {search_word} are shown') -def verify_found_results_text(context, search_word): - assert search_word.lower() in context.driver.current_url.lower(), \ - f'Expected query not in {context.driver.current_url.lower()}' diff --git a/features/steps/signin_steps.py b/features/steps/signin_steps.py new file mode 100644 index 000000000..d37823e7a --- /dev/null +++ b/features/steps/signin_steps.py @@ -0,0 +1,23 @@ + +from behave import given,when,then +from selenium.webdriver.common.by import By + + +@given('Open the Target page') +def open_main(context): + context.driver.get("https://www.target.com/") + +@when('Click signin button') +def click_signin_button(context): + context.driver.find_element(By.XPATH,"//span[contains(.,'Account')]").click() + context.driver.find_element(By.XPATH,"//button[@data-test='accountNav-signIn']").click() + +@then('Verify signin form opened') +def verify_signin_form_opened(context): + actual_text= context.driver.find_element(By.XPATH,"//h1[contains(.,'Sign in or create account')]").text + expected_text= 'Sign in or create account' + assert actual_text in expected_text, f'Expected:{expected_text} but got Actual:{actual_text}' + + + + diff --git a/features/tests/__init__.py b/features/tests/__init__.py deleted file mode 100755 index e69de29bb..000000000 diff --git a/features/tests/cart.feature b/features/tests/cart.feature new file mode 100644 index 000000000..ac9554f67 --- /dev/null +++ b/features/tests/cart.feature @@ -0,0 +1,7 @@ +Feature: Target empty cart test + + Scenario: Your cart is empty message is shown + Given Open Target page + When Click on add to cart icon + Then verify empty cart message + diff --git a/features/tests/product_search.feature b/features/tests/product_search.feature deleted file mode 100755 index 36d6913cf..000000000 --- a/features/tests/product_search.feature +++ /dev/null @@ -1,7 +0,0 @@ -Feature: Test Scenarios for Search functionality - - Scenario: User can search for a product - Given Open Google page - When Input Car into search field - And Click on search icon - Then Product results for Car are shown \ No newline at end of file diff --git a/features/tests/signin.feature b/features/tests/signin.feature new file mode 100644 index 000000000..82c1f328c --- /dev/null +++ b/features/tests/signin.feature @@ -0,0 +1,8 @@ +# Created by Davon Gilliam at 10/11/2025 +Feature: Test for Logged Out Users signing in. + # Enter feature description here + + Scenario: User can navigate to signin page. + Given Open the Target page + When Click signin button + Then Verify signin form opened \ No newline at end of file