From 853667500bba6114c8644bd89a9adb8e1cd4c573 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Aug 2024 17:46:24 -0400 Subject: [PATCH 01/19] Update automated search script --- sample_script.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample_script.py b/sample_script.py index 3925e946..096f59ea 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('table') # 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 'table'.lower() in driver.current_url.lower(), f"Expected query not in {driver.current_url.lower()}" print('Test Passed') driver.quit() From 704d729f5f18eaba9f70e8455f50fab4d8820014 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Sep 2024 11:45:14 -0400 Subject: [PATCH 02/19] Update automated search script --- features/steps/homework 2 | 0 features/steps/homework lesson 2.py | 0 features/steps/python.py | 0 locators.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 features/steps/homework 2 create mode 100644 features/steps/homework lesson 2.py create mode 100644 features/steps/python.py create mode 100644 locators.py diff --git a/features/steps/homework 2 b/features/steps/homework 2 new file mode 100644 index 00000000..e69de29b diff --git a/features/steps/homework lesson 2.py b/features/steps/homework lesson 2.py new file mode 100644 index 00000000..e69de29b diff --git a/features/steps/python.py b/features/steps/python.py new file mode 100644 index 00000000..e69de29b diff --git a/locators.py b/locators.py new file mode 100644 index 00000000..e69de29b From c6e97081bde664cc3fa89729ffad412f41169ff8 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Thu, 21 Nov 2024 15:52:05 -0500 Subject: [PATCH 03/19] Update automated search script --- features/steps/homework 2 | 18 +++++++++++++ features/steps/homework 2.py | 39 +++++++++++++++++++++++++++++ features/steps/homework lesson 2.py | 27 ++++++++++++++++++++ features/steps/practice | 13 ++++++++++ features/steps/practice.py | 29 +++++++++++++++++++++ features/steps/python.py | 29 +++++++++++++++++++++ locators.py | 15 +++++++++++ 7 files changed, 170 insertions(+) create mode 100644 features/steps/homework 2.py create mode 100644 features/steps/practice create mode 100644 features/steps/practice.py diff --git a/features/steps/homework 2 b/features/steps/homework 2 index e69de29b..00d6489b 100644 --- a/features/steps/homework 2 +++ b/features/steps/homework 2 @@ -0,0 +1,18 @@ +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 + +# 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.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&') + +driver.find_element(By.XPATH, "" \ No newline at end of file diff --git a/features/steps/homework 2.py b/features/steps/homework 2.py new file mode 100644 index 00000000..97891f94 --- /dev/null +++ b/features/steps/homework 2.py @@ -0,0 +1,39 @@ +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 + +# 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') + +sleep(2) +#verify if sign in button works +driver.find_element(By.XPATH,"//a[@data-test='@web/AccountLink']").click() +sleep(2) + +#verify if side navigation "sign in" button works +driver.find_element(By.XPATH,"//a[@data-test='accountNav-signIn']").click() +sleep(2) + +#SignIn button is shown +driver.find_element(By.ID,"login").click() + + + + + + + + + + + diff --git a/features/steps/homework lesson 2.py b/features/steps/homework lesson 2.py index e69de29b..febc2fff 100644 --- a/features/steps/homework lesson 2.py +++ b/features/steps/homework lesson 2.py @@ -0,0 +1,27 @@ +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 + +# 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.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&') + +driver.find_element(By.XPATH, "//i[@class='a-icon a-icon-logo']") +driver.find_element(By.ID,'ap_email') +driver.find_element(By.ID,'continue') +driver.find_element(By.ID, "auth-fpp-link-bottom") +driver.find_element(By.ID, "ap-other-signin-issues-link") +driver.find_element(By.ID,"createAccountSubmit") +driver.find_element(By.XPATH,"//span[@class='a-expander-prompt']") +driver.find_element(By.XPATH,'//a[@href="/gp/help/customer/display.html/ref=ap_signin_notification_privacy_notice?ie=UTF8&nodeId=468496"]') +driver.find_element(By.XPATH,'//a[@href="/gp/help/customer/display.html/ref=ap_signin_notification_condition_of_use?ie=UTF8&nodeId=508088"]') + diff --git a/features/steps/practice b/features/steps/practice new file mode 100644 index 00000000..e0f96bdd --- /dev/null +++ b/features/steps/practice @@ -0,0 +1,13 @@ +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 + +# 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() diff --git a/features/steps/practice.py b/features/steps/practice.py new file mode 100644 index 00000000..4feab8c5 --- /dev/null +++ b/features/steps/practice.py @@ -0,0 +1,29 @@ +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 + +# 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() + +driver.get('https://www.bestbuy.com/') + +driver.find_element(By.ID,"gh-search-input").send_keys('headphones') +sleep(5) + +driver.find_element(By.XPATH,"//button[@aria-label='submit search']").click() + +driver.quit() + + + + + + + diff --git a/features/steps/python.py b/features/steps/python.py index e69de29b..82dbdcfa 100644 --- a/features/steps/python.py +++ b/features/steps/python.py @@ -0,0 +1,29 @@ +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 + +# 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.amazon.com/') + +# Locate element: +# driver.find_element() # By. / value +# Locate by ID: +driver.find_element(By.ID, 'twotabsearchtextbox') +driver.find_element(By.ID, 'nav-logo-sprites') + +# By Xpath, using 1 attribute +driver.find_element(By.XPATH, "//img[@alt='Shop Studio Pro headphones']") +driver.find_element(By.XPATH, "//input[@name='field-keywords']") +driver.find_element(By.XPATH, "//input[@placeholder='Search Amazon']") +# By Xpath, multiple attributes +driver.find_element(By.XPATH, "//a[@class='nav-a ' and @href='/gp/bestsellers/?ref_=nav_cs_bestsellers' and @tabindex='0']") \ No newline at end of file diff --git a/locators.py b/locators.py index e69de29b..2d2a66e5 100644 --- a/locators.py +++ b/locators.py @@ -0,0 +1,15 @@ +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 + +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.google.com/') From b3ed8138527a07d0e66eaed0009d2cbddafdf2b4 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Fri, 6 Dec 2024 10:50:37 -0500 Subject: [PATCH 04/19] Update automated search script --- features/tests/homework lesson 2.py | 24 ++++++++++++++++++++ features/tests/practice.py | 20 +++++++++++++++++ features/tests/target homework lesson 2.py | 26 ++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 features/tests/homework lesson 2.py create mode 100644 features/tests/practice.py create mode 100644 features/tests/target homework lesson 2.py diff --git a/features/tests/homework lesson 2.py b/features/tests/homework lesson 2.py new file mode 100644 index 00000000..5dd11982 --- /dev/null +++ b/features/tests/homework lesson 2.py @@ -0,0 +1,24 @@ +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 + +# 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() + +driver.get('https://www.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&') +driver.find_element(By.XPATH,"//i[@aria-label='Amazon']") +driver.find_element(By.ID,'ap_email') +driver.find_element(By.ID,'continue') +driver.find_element(By.XPATH,"//a[text()='Conditions of Use']") +driver.find_element(By.XPATH,"//a[text()='Privacy Notice']") +driver.find_element(By.XPATH,"//a[@data-action='a-expander-toggle']") +driver.find_element(By.ID,'auth-fpp-link-bottom') +driver.find_element(By.ID,'ap-other-signin-issues-link') +driver.find_element(By.ID,'createAccountSubmit') diff --git a/features/tests/practice.py b/features/tests/practice.py new file mode 100644 index 00000000..afefcfb6 --- /dev/null +++ b/features/tests/practice.py @@ -0,0 +1,20 @@ +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 + +# 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() + +driver.get('www.amazon.com') +driver.find_element(By.ID,'search').send_keys('tea') + +sleep(5) + + diff --git a/features/tests/target homework lesson 2.py b/features/tests/target homework lesson 2.py new file mode 100644 index 00000000..9298121c --- /dev/null +++ b/features/tests/target homework lesson 2.py @@ -0,0 +1,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 + +# 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() + +driver.get('www.target.com') +driver.find_element(By.XPATH,"//span[text()='Sign in']").click() +driver.find_element(By.XPATH,"//button[@data-test='accountNav-signIn']").click() +sleep(10) +#Verification +expected_result ='Sign into your Target account' +actual_result =driver.find_element(By.XPATH,"//h1[@class='sc-fe064f5c-0 sc-315b8ab9-2 lnvRvp diHlfH']") +assert expected_result in actual_result,f'Expected text {expected_result} not in actual {actual_result}' +print("Test Case passed") + +driver.find_element(By.ID,'login') + From 0908df1f31fa4ce249aa7b2fede3cc719c5ec6bf Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Sat, 7 Dec 2024 18:10:25 -0500 Subject: [PATCH 05/19] Update automated search script --- features/steps/CSS_selectors amazon.py | 27 ++++++++++++++++++++++ features/tests/target homework lesson 2.py | 1 + features/tests/target search.feature | 6 +++++ 3 files changed, 34 insertions(+) create mode 100644 features/steps/CSS_selectors amazon.py create mode 100644 features/tests/target search.feature diff --git a/features/steps/CSS_selectors amazon.py b/features/steps/CSS_selectors amazon.py new file mode 100644 index 00000000..0b552e33 --- /dev/null +++ b/features/steps/CSS_selectors amazon.py @@ -0,0 +1,27 @@ +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 + +# 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() + +driver.get('https://www.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0') +sleep(5) +driver.find_element(By.CSS_SELECTOR,'i.a-icon.a-icon-logo') +driver.find_element(By.CSS_SELECTOR,'h1.a-spacing-small') +driver.find_element(By.CSS_SELECTOR,'#ap_customer_name') +driver.find_element(By.CSS_SELECTOR,'#ap_email') +driver.find_element(By.CSS_SELECTOR,'#ap_password') +driver.find_element(By.CSS_SELECTOR,'div.a-alert-content') +driver.find_element(By.CSS_SELECTOR,'#ap_password_check') +driver.find_element(By.CSS_SELECTOR,'#continue') +driver.find_element(By.CSS_SELECTOR,"[href*='/gp/help/customer/display.html/ref=ap_register_notification_condition_of_use']") +driver.find_element(By.CSS_SELECTOR,"[href*='/gp/help/customer/display.html/ref=ap_register_notification_privacy_notice?i']") +driver.find_element(By.CSS_SELECTOR,"a.a-link-emphasis") diff --git a/features/tests/target homework lesson 2.py b/features/tests/target homework lesson 2.py index 9298121c..b6bc2374 100644 --- a/features/tests/target homework lesson 2.py +++ b/features/tests/target homework lesson 2.py @@ -13,6 +13,7 @@ driver.maximize_window() driver.get('www.target.com') +sleep(5) driver.find_element(By.XPATH,"//span[text()='Sign in']").click() driver.find_element(By.XPATH,"//button[@data-test='accountNav-signIn']").click() sleep(10) diff --git a/features/tests/target search.feature b/features/tests/target search.feature new file mode 100644 index 00000000..298213fa --- /dev/null +++ b/features/tests/target search.feature @@ -0,0 +1,6 @@ +# Created by Pooja at 12/7/2024 +Feature: # Enter feature name here + # Enter feature description here + + Scenario: # Enter scenario name here + # Enter steps here \ No newline at end of file From 237ea0df07902232625ff1e1d522e616c4f2bbfe Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Sat, 7 Dec 2024 18:57:03 -0500 Subject: [PATCH 06/19] Update automated search script --- features/steps/target search.py | 38 ++++++++++++++++++++++++++++ features/tests/target search.feature | 20 +++++++++++---- 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 features/steps/target search.py diff --git a/features/steps/target search.py b/features/steps/target search.py new file mode 100644 index 00000000..bb0cfac8 --- /dev/null +++ b/features/steps/target search.py @@ -0,0 +1,38 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then +from time import sleep + + +@given('Open Target page') +def open_target(context): + context.driver.get('https://www.target.com') + sleep(3) + + +@when('Click on cart button') +def click_cart(context): + context.driver.find_element(By.CSS_SELECTOR,"a[data-test='@web/CartLink']").click() + sleep(5) + + +@then('Your cart is empty message displays') +def message_empty(context): + context.driver.find_element(By.CSS_SELECTOR,"h1.sc-fe064f5c-0") + sleep(3) + + +@when('Click on sign on button') +def click_sign(context): + context.driver.find_element(By.CSS_SELECTOR,"span.sc-58ad44c0-3").click() + sleep(3) + + +@when('Click sign in from side navigation') +def message_signin(context): + context.driver.find_element(By.CSS_SELECTOR,"button[data-test='accountNav-signIn']").click() + sleep(3) + +@then('Sign in message displays') +def sign_in_message(context): + context.driver.find_element(By.CSS_SELECTOR,".sc-fe064f5c-0") + diff --git a/features/tests/target search.feature b/features/tests/target search.feature index 298213fa..b9db1689 100644 --- a/features/tests/target search.feature +++ b/features/tests/target search.feature @@ -1,6 +1,16 @@ -# Created by Pooja at 12/7/2024 -Feature: # Enter feature name here - # Enter feature description here +Feature: Your cart is empty message shows + + Scenario: Cart is empty message shows + Given Open Target page + When Click on cart button + Then Your cart is empty message displays + +Feature: Logged out user can navigate to sign in page + + + Scenario: Clicking on sign on page leads to sign in page + Given Open Target page + When Click on sign on button + When Click sign in from side navigation + Then Sign in message displays - Scenario: # Enter scenario name here - # Enter steps here \ No newline at end of file From 2679d06881c6e313a6bbbd3b194d594fc9379ee3 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Thu, 19 Dec 2024 11:16:51 -0500 Subject: [PATCH 07/19] Add code to Git --- ...ctors amazon.py => CSS_selectors amazon.py | 0 features/steps/__init__.py | 0 features/steps/practice.py | 29 ----------------- features/steps/product_search.py | 32 ------------------- features/steps/target circle steps.py | 19 +++++++++++ features/steps/target search.py | 32 +++++++------------ features/tests/__init__.py | 0 features/tests/homework lesson 2.py | 24 -------------- features/tests/practice.py | 20 ------------ features/tests/product_search.feature | 7 ---- features/tests/target circle page.feature | 9 ++++++ features/tests/target search.feature | 21 ++++++------ features/steps/homework 2 => homework 2 | 0 features/steps/homework 2.py => homework 2.py | 0 ...mework lesson 2.py => homework lesson 2.py | 0 features/steps/practice => practice | 0 features/steps/python.py => python.py | 0 ...lesson 2.py => target homework lesson 2.py | 0 18 files changed, 49 insertions(+), 144 deletions(-) rename features/steps/CSS_selectors amazon.py => CSS_selectors amazon.py (100%) delete mode 100755 features/steps/__init__.py delete mode 100644 features/steps/practice.py delete mode 100755 features/steps/product_search.py create mode 100644 features/steps/target circle steps.py delete mode 100755 features/tests/__init__.py delete mode 100644 features/tests/homework lesson 2.py delete mode 100644 features/tests/practice.py delete mode 100755 features/tests/product_search.feature create mode 100644 features/tests/target circle page.feature rename features/steps/homework 2 => homework 2 (100%) rename features/steps/homework 2.py => homework 2.py (100%) rename features/steps/homework lesson 2.py => homework lesson 2.py (100%) rename features/steps/practice => practice (100%) rename features/steps/python.py => python.py (100%) rename features/tests/target homework lesson 2.py => target homework lesson 2.py (100%) diff --git a/features/steps/CSS_selectors amazon.py b/CSS_selectors amazon.py similarity index 100% rename from features/steps/CSS_selectors amazon.py rename to CSS_selectors amazon.py diff --git a/features/steps/__init__.py b/features/steps/__init__.py deleted file mode 100755 index e69de29b..00000000 diff --git a/features/steps/practice.py b/features/steps/practice.py deleted file mode 100644 index 4feab8c5..00000000 --- a/features/steps/practice.py +++ /dev/null @@ -1,29 +0,0 @@ -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 - -# 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() - -driver.get('https://www.bestbuy.com/') - -driver.find_element(By.ID,"gh-search-input").send_keys('headphones') -sleep(5) - -driver.find_element(By.XPATH,"//button[@aria-label='submit search']").click() - -driver.quit() - - - - - - - diff --git a/features/steps/product_search.py b/features/steps/product_search.py deleted file mode 100755 index 4e142cb4..00000000 --- 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/target circle steps.py b/features/steps/target circle steps.py new file mode 100644 index 00000000..0ee0d936 --- /dev/null +++ b/features/steps/target circle steps.py @@ -0,0 +1,19 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then +from time import sleep + +@when('Click on Target Circle button') +def search_circle(context): + context.driver.find_element(By.CSS_SELECTOR,"").click() +sleep(5) + + +@then('Verify at least 10 cells present') +def results_for_circle(context): + + actual_results_circle = context.driver.find_elements(By.CSS_SELECTOR, "[data-test='@web/slingshot-components/CellsComponent/Link']").text + + print(actual_results_circle) + + assert len(actual_results_circle) >= 10,f'Expected 10 links, but got {len(actual_results_circle)}' +sleep(3) \ No newline at end of file diff --git a/features/steps/target search.py b/features/steps/target search.py index bb0cfac8..05eb1d34 100644 --- a/features/steps/target search.py +++ b/features/steps/target search.py @@ -6,33 +6,25 @@ @given('Open Target page') def open_target(context): context.driver.get('https://www.target.com') - sleep(3) +sleep(3) -@when('Click on cart button') -def click_cart(context): - context.driver.find_element(By.CSS_SELECTOR,"a[data-test='@web/CartLink']").click() - sleep(5) +@when('search for a {product}') +def search_product(context,product): + context.driver.find_element(By.CSS_SELECTOR,"[data-test='@web/Search/SearchInput']").click() +sleep(5) -@then('Your cart is empty message displays') -def message_empty(context): - context.driver.find_element(By.CSS_SELECTOR,"h1.sc-fe064f5c-0") - sleep(3) +@then('verify search for results are shown for {product}') +def results_for_product(context,product): + actual_result = context.driver.find_element(By.CSS_SELECTOR, "[data-test='resultsHeading']").text + + assert product in actual_result,f'Expected result {product} not in {actual_result}' +sleep(3) + -@when('Click on sign on button') -def click_sign(context): - context.driver.find_element(By.CSS_SELECTOR,"span.sc-58ad44c0-3").click() - sleep(3) -@when('Click sign in from side navigation') -def message_signin(context): - context.driver.find_element(By.CSS_SELECTOR,"button[data-test='accountNav-signIn']").click() - sleep(3) -@then('Sign in message displays') -def sign_in_message(context): - context.driver.find_element(By.CSS_SELECTOR,".sc-fe064f5c-0") diff --git a/features/tests/__init__.py b/features/tests/__init__.py deleted file mode 100755 index e69de29b..00000000 diff --git a/features/tests/homework lesson 2.py b/features/tests/homework lesson 2.py deleted file mode 100644 index 5dd11982..00000000 --- a/features/tests/homework lesson 2.py +++ /dev/null @@ -1,24 +0,0 @@ -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 - -# 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() - -driver.get('https://www.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&') -driver.find_element(By.XPATH,"//i[@aria-label='Amazon']") -driver.find_element(By.ID,'ap_email') -driver.find_element(By.ID,'continue') -driver.find_element(By.XPATH,"//a[text()='Conditions of Use']") -driver.find_element(By.XPATH,"//a[text()='Privacy Notice']") -driver.find_element(By.XPATH,"//a[@data-action='a-expander-toggle']") -driver.find_element(By.ID,'auth-fpp-link-bottom') -driver.find_element(By.ID,'ap-other-signin-issues-link') -driver.find_element(By.ID,'createAccountSubmit') diff --git a/features/tests/practice.py b/features/tests/practice.py deleted file mode 100644 index afefcfb6..00000000 --- a/features/tests/practice.py +++ /dev/null @@ -1,20 +0,0 @@ -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 - -# 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() - -driver.get('www.amazon.com') -driver.find_element(By.ID,'search').send_keys('tea') - -sleep(5) - - diff --git a/features/tests/product_search.feature b/features/tests/product_search.feature deleted file mode 100755 index 36d6913c..00000000 --- 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/target circle page.feature b/features/tests/target circle page.feature new file mode 100644 index 00000000..9a950e30 --- /dev/null +++ b/features/tests/target circle page.feature @@ -0,0 +1,9 @@ + +Feature: User can see 10 cells when on Target circle page + + + Scenario: + Given Open Target page + When Click on Target Circle button + Then Verify at least 10 cells present + diff --git a/features/tests/target search.feature b/features/tests/target search.feature index b9db1689..60a73130 100644 --- a/features/tests/target search.feature +++ b/features/tests/target search.feature @@ -1,16 +1,13 @@ -Feature: Your cart is empty message shows +Feature: Target search page - Scenario: Cart is empty message shows + Scenario Outline: User can search for a product Given Open Target page - When Click on cart button - Then Your cart is empty message displays + When search for a + Then verify search for results are shown for + Examples: + | product | + | coffee | + | mug | + | tea | -Feature: Logged out user can navigate to sign in page - - - Scenario: Clicking on sign on page leads to sign in page - Given Open Target page - When Click on sign on button - When Click sign in from side navigation - Then Sign in message displays diff --git a/features/steps/homework 2 b/homework 2 similarity index 100% rename from features/steps/homework 2 rename to homework 2 diff --git a/features/steps/homework 2.py b/homework 2.py similarity index 100% rename from features/steps/homework 2.py rename to homework 2.py diff --git a/features/steps/homework lesson 2.py b/homework lesson 2.py similarity index 100% rename from features/steps/homework lesson 2.py rename to homework lesson 2.py diff --git a/features/steps/practice b/practice similarity index 100% rename from features/steps/practice rename to practice diff --git a/features/steps/python.py b/python.py similarity index 100% rename from features/steps/python.py rename to python.py diff --git a/features/tests/target homework lesson 2.py b/target homework lesson 2.py similarity index 100% rename from features/tests/target homework lesson 2.py rename to target homework lesson 2.py From 78db4d9420f502ccded9d0b88283bef3df614c71 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Thu, 19 Dec 2024 11:49:35 -0500 Subject: [PATCH 08/19] Add code to git --- features/steps/target cart steps.py | 29 ++++++++++++++++++++++ features/tests/target cart search .feature | 10 ++++++++ 2 files changed, 39 insertions(+) create mode 100644 features/steps/target cart steps.py create mode 100644 features/tests/target cart search .feature diff --git a/features/steps/target cart steps.py b/features/steps/target cart steps.py new file mode 100644 index 00000000..39e75f0a --- /dev/null +++ b/features/steps/target cart steps.py @@ -0,0 +1,29 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then +from time import sleep + +@when('Click on product of choice') +def click_product(context): + context.driver.find_element(By.CSS_SELECTOR, "[src='https://target.scene7.com/is/image/Target/GUEST_b99b87c5-8b59-42ce-a51e-336ccc789a01']").click() + + +@when('Click on add to cart button') +def click_add(context): + context.driver.find_element(By.CSS_SELECTOR,"[aria-label='Add to cart for The Official Taylor Swift | The Eras Tour Book (Target Exclusive)']") + + +@when('Click on cart icon') +def click_cart(context): + context.driver.find_element(By.CSS_SELECTOR, "[data-test='@web/CartIcon']").click() + + +@then('Verify product is in cart') +def verify_product(context): + + expected_result = '$39.99 subtotal' + actual_cart = context.driver.find_element(By.XPATH, "//span[text()='$39.99 subtotal']").text + + assert expected_result == actual_cart,f'{expected_result} is not in {actual_cart}' + + + diff --git a/features/tests/target cart search .feature b/features/tests/target cart search .feature new file mode 100644 index 00000000..2138e130 --- /dev/null +++ b/features/tests/target cart search .feature @@ -0,0 +1,10 @@ + +Feature: Adding products to Target cart + + + Scenario: User can add a product into target cart + Given Open Target page + When Click on product of choice + When Click on add to cart button + When Click on cart icon + Then Verify product is in cart From d2c23f005de1e81d30b8860d6d86d256206b5d4f Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Fri, 20 Dec 2024 10:11:42 -0500 Subject: [PATCH 09/19] Add new code to github --- features/steps/target cart steps.py | 55 ++++++++++++++++------ features/steps/target circle steps.py | 12 ++--- features/steps/target search.py | 12 +++-- features/tests/target cart search .feature | 13 +++-- 4 files changed, 62 insertions(+), 30 deletions(-) diff --git a/features/steps/target cart steps.py b/features/steps/target cart steps.py index 39e75f0a..ead648a6 100644 --- a/features/steps/target cart steps.py +++ b/features/steps/target cart steps.py @@ -2,28 +2,55 @@ from behave import given, when, then from time import sleep -@when('Click on product of choice') -def click_product(context): - context.driver.find_element(By.CSS_SELECTOR, "[src='https://target.scene7.com/is/image/Target/GUEST_b99b87c5-8b59-42ce-a51e-336ccc789a01']").click() +@when('Click on Categories') +def click_categories(context): + context.driver.find_element(By.CSS_SELECTOR, "[aria-label='Categories']").click() + sleep(2) -@when('Click on add to cart button') -def click_add(context): - context.driver.find_element(By.CSS_SELECTOR,"[aria-label='Add to cart for The Official Taylor Swift | The Eras Tour Book (Target Exclusive)']") +@when('Click on Christmas button') +def click_christmas(context): + context.driver.find_element(By.CSS_SELECTOR, "[data-url='/c/christmas/-/N-5xt30']").click() + sleep(2) -@when('Click on cart icon') -def click_cart(context): - context.driver.find_element(By.CSS_SELECTOR, "[data-test='@web/CartIcon']").click() +@when('Click on Christmas Deals') +def click_christmas_deals(context): + context.driver.find_element(By.CSS_SELECTOR,"[data-url='/c/christmas-deals/-/N-4rr05']").click() + sleep(2) -@then('Verify product is in cart') -def verify_product(context): +@when('Click on Christmas Trees') +def click_christmas_trees(context): + context.driver.find_element(By.CSS_SELECTOR,"[src='https://target.scene7.com/is/image/Target/GUEST_5ea06363-e13a-4069-8469-cd7cbf892955?wid=315&hei=315&qlt=60&fmt=webp']").click() + sleep(5) - expected_result = '$39.99 subtotal' - actual_cart = context.driver.find_element(By.XPATH, "//span[text()='$39.99 subtotal']").text - assert expected_result == actual_cart,f'{expected_result} is not in {actual_cart}' +@when('Click on first christmas tree') +def click_first_tree(context): + context.driver.find_element(By.CSS_SELECTOR,"[data-test='@web/ProductCard/body']").click() + sleep(5) + + +@when('Click on Add to cart') +def click_add_to_cart(context): + context.driver.find_element(By.CSS_SELECTOR,"[aria-label*='Artificial Christmas Tree Holiday Decor with 450']").click() + sleep(5) + + +@when('Click on view cart and checkout button') +def view_cart(context): + context.driver.find_element(By.CSS_SELECTOR,"[href='/cart']").click() + sleep(3) + + +@then('Verify if result is shown') +def verify_result(context): + expected_value = "$234.99 subtotal 1 item" + actual_result= context.driver.find_element(By.CSS_SELECTOR,"#cart-summary-heading").click() + assert expected_value == actual_result,f'{expected_value} != {actual_result}' + print(actual_result) + diff --git a/features/steps/target circle steps.py b/features/steps/target circle steps.py index 0ee0d936..58c77f64 100644 --- a/features/steps/target circle steps.py +++ b/features/steps/target circle steps.py @@ -4,16 +4,14 @@ @when('Click on Target Circle button') def search_circle(context): - context.driver.find_element(By.CSS_SELECTOR,"").click() + context.driver.find_element(By.CSS_SELECTOR,"#utilityNav-circle").click() sleep(5) @then('Verify at least 10 cells present') def results_for_circle(context): + actual_results_circle = context.driver.find_elements(By.CSS_SELECTOR, "[data-test='@web/slingshot-components/CellsComponent/Link']") + print(actual_results_circle) - actual_results_circle = context.driver.find_elements(By.CSS_SELECTOR, "[data-test='@web/slingshot-components/CellsComponent/Link']").text - - print(actual_results_circle) - - assert len(actual_results_circle) >= 10,f'Expected 10 links, but got {len(actual_results_circle)}' -sleep(3) \ No newline at end of file + assert len(actual_results_circle) >= 10,f'Expected 10 links, but got {len(actual_results_circle)}' + sleep(3) \ No newline at end of file diff --git a/features/steps/target search.py b/features/steps/target search.py index 05eb1d34..00436455 100644 --- a/features/steps/target search.py +++ b/features/steps/target search.py @@ -6,13 +6,15 @@ @given('Open Target page') def open_target(context): context.driver.get('https://www.target.com') -sleep(3) + sleep(3) @when('search for a {product}') -def search_product(context,product): - context.driver.find_element(By.CSS_SELECTOR,"[data-test='@web/Search/SearchInput']").click() -sleep(5) +def search_product(context, product): + context.driver.find_element(By.CSS_SELECTOR, "[data-test='@web/Search/SearchInput']").send_keys(product) + sleep(1) + context.driver.find_element(By.CSS_SELECTOR, "[data-test='@web/Search/SearchButton']").click() + sleep(3) @then('verify search for results are shown for {product}') @@ -20,7 +22,7 @@ def results_for_product(context,product): actual_result = context.driver.find_element(By.CSS_SELECTOR, "[data-test='resultsHeading']").text assert product in actual_result,f'Expected result {product} not in {actual_result}' -sleep(3) + sleep(3) diff --git a/features/tests/target cart search .feature b/features/tests/target cart search .feature index 2138e130..0f5b9c13 100644 --- a/features/tests/target cart search .feature +++ b/features/tests/target cart search .feature @@ -4,7 +4,12 @@ Feature: Adding products to Target cart Scenario: User can add a product into target cart Given Open Target page - When Click on product of choice - When Click on add to cart button - When Click on cart icon - Then Verify product is in cart + When Click on Categories + When Click on Christmas button + When Click on Christmas Deals + When Click on Christmas Trees + When Click on first christmas tree + When Click on Add to cart + When Click on view cart and checkout button + Then Verify if result is shown + From 1020af5d95ab34c111a6a5c126526f84a928173b Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Wed, 25 Dec 2024 11:19:42 -0500 Subject: [PATCH 10/19] updated PoojaPatel.txt to PP.txt --- PP.txt | 0 features/steps/steps for practice.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 PP.txt create mode 100644 features/steps/steps for practice.py diff --git a/PP.txt b/PP.txt new file mode 100644 index 00000000..e69de29b diff --git a/features/steps/steps for practice.py b/features/steps/steps for practice.py new file mode 100644 index 00000000..e69de29b From 3976313639f09cc2866feefdb99d658b14b9d8a4 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Sat, 28 Dec 2024 17:56:00 -0500 Subject: [PATCH 11/19] Lesson 5 HW --- .../__init__.py | 0 Application/application.py | 25 +++++++++++ Pages/Main_page.py | 8 ++++ Pages/__init__.py | 0 Pages/base_page.py | 21 ++++++++++ Pages/cart_page.py | 5 +++ Pages/circle_page.py | 16 +++++++ features/environment.py | 10 ++++- features/steps/product colors steps.py | 38 +++++++++++++++++ features/steps/target cart steps.py | 42 ++++++++++++------- features/steps/target circle steps.py | 8 ++-- features/tests/Product colors .feature | 7 ++++ sample_script.py | 1 + 13 files changed, 162 insertions(+), 19 deletions(-) rename features/steps/steps for practice.py => Application/__init__.py (100%) create mode 100644 Application/application.py create mode 100644 Pages/Main_page.py create mode 100644 Pages/__init__.py create mode 100644 Pages/base_page.py create mode 100644 Pages/cart_page.py create mode 100644 Pages/circle_page.py create mode 100644 features/steps/product colors steps.py create mode 100644 features/tests/Product colors .feature diff --git a/features/steps/steps for practice.py b/Application/__init__.py similarity index 100% rename from features/steps/steps for practice.py rename to Application/__init__.py diff --git a/Application/application.py b/Application/application.py new file mode 100644 index 00000000..23c9b7b5 --- /dev/null +++ b/Application/application.py @@ -0,0 +1,25 @@ +from pages.base_page import BasePage +from pages.Main_page import MainPage +from pages.circle_page import CirclePage +from pages.cart_page import CartPage + +from locators import driver + + +class Application: + def __init__(self, driver): + self.driver = driver + self.base_page=BasePage(driver) + self.main_page=MainPage(driver) + self.circle_page=CirclePage(driver) + self.cart_page=CartPage(driver) + +app=Application(driver) +app.base_page.function +app.main_page.function +app.circle_page.function +app.cart_page.function + + + + diff --git a/Pages/Main_page.py b/Pages/Main_page.py new file mode 100644 index 00000000..aa108b93 --- /dev/null +++ b/Pages/Main_page.py @@ -0,0 +1,8 @@ +from Pages.base_page import BasePage + +class MainPage(BasePage): + + def open_main_page(self): + self.open_url('www.target.com') + + diff --git a/Pages/__init__.py b/Pages/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Pages/base_page.py b/Pages/base_page.py new file mode 100644 index 00000000..40f18ca3 --- /dev/null +++ b/Pages/base_page.py @@ -0,0 +1,21 @@ +class BasePage: + + + def __init__(self, driver): + self.driver = driver + + + def open_url(self,url): + self.driver.get(url) + + + def click(self,*locator): + self.driver.find_element(*locator).click() + + + def find_element(self,*locator): + return self.driver.find_element(*locator) + + + def input_text(self,text,*locator): + self.driver.find_element(*locator).send_keys(text) diff --git a/Pages/cart_page.py b/Pages/cart_page.py new file mode 100644 index 00000000..1233624b --- /dev/null +++ b/Pages/cart_page.py @@ -0,0 +1,5 @@ +from pages.base_page import Basepage + +class CartPage(Basepage): + def click_cart(self): + self.click_categories \ No newline at end of file diff --git a/Pages/circle_page.py b/Pages/circle_page.py new file mode 100644 index 00000000..dfb03add --- /dev/null +++ b/Pages/circle_page.py @@ -0,0 +1,16 @@ +from selenium.webdriver.common.by import By +from Pages.base_page import BasePage + +SEARCH_CIRCLE = By.CSS_SELECTOR,"#utilityNav-circle" +RESULTS = By.CSS_SELECTOR, "[data-test='@web/slingshot-components/CellsComponent/Link']" + +class CirclePage(BasePage): + + def click_circle_button(self): + self.click(self,*SEARCH_CIRCLE) + + def find_element(self,*RESULTS): + print('Searching by {*RESULTS}') + + + diff --git a/features/environment.py b/features/environment.py index 1275460a..6f0a2984 100755 --- a/features/environment.py +++ b/features/environment.py @@ -1,6 +1,10 @@ from selenium import webdriver from selenium.webdriver.chrome.service import Service +from selenium.webdriver.support.wait import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager +from app.application import Application + + def browser_init(context): @@ -12,7 +16,11 @@ def browser_init(context): context.driver = webdriver.Chrome(service=service) context.driver.maximize_window() - context.driver.implicitly_wait(4) + context.driver.implicitly_wait(5) + context.driver.wait = WebDriverWait(context.driver, 15) + context.app = Application(context.driver) + context.app.implicitly_wait(5) + def before_scenario(context, scenario): diff --git a/features/steps/product colors steps.py b/features/steps/product colors steps.py new file mode 100644 index 00000000..03166a6a --- /dev/null +++ b/features/steps/product colors steps.py @@ -0,0 +1,38 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then +from time import sleep + + + +@given("a specific product") +def product_page(context): + context.driver.get("https://www.target.com/p/A-54551690") +sleep (3) + + +@then("Verify if product with specific color is displayed") +def verify_product_color(context): + product_color = ["Blue Tint", "Denim Blue", "Raven", "Marine"] + actual_colors = [] + + colors = context.driver.find_elements(By.CSS_SELECTOR,"div[aria-label='Carousel']") + +for color in colors: + color.click() + + selected_colors= context.driver.find_element(By.CSS_SELECTOR,"[data-test='@web/VariationComponent'] div") + print('Current color',selected_colors) + + selected_color = selected_color.split('\n')[1] # remove 'Color\n' part, keep Black' + actual_colors.append(selected_color) + print(actual_colors) + +assert expected_colors == actual_colors, f'Expected {expected_colors} did not match actual {actual_colors}' + + + + + + + + diff --git a/features/steps/target cart steps.py b/features/steps/target cart steps.py index ead648a6..aeea828b 100644 --- a/features/steps/target cart steps.py +++ b/features/steps/target cart steps.py @@ -1,47 +1,59 @@ from selenium.webdriver.common.by import By from behave import given, when, then -from time import sleep +from selenium.webdriver.support import expected_conditions as EC +from selenium import webdriver +driver = webdriver.Chrome() +driver.implicitly_wait(5) + + +CLICK_CATEGORIES = By.CSS_SELECTOR, "[aria-label='Categories']" +CLICK_CHRISTMAS = By.CSS_SELECTOR, "[data-url='/c/christmas/-/N-5xt30']" +CLICK_DEALS = By.CSS_SELECTOR,"[data-url='/c/christmas-deals/-/N-4rr05']" +CLICK_TREES = By.CSS_SELECTOR,"[src='https://target.scene7.com/is/image/Target/GUEST_5ea06363-e13a-4069-8469-cd7cbf892955?wid=315&hei=315&qlt=60&fmt=webp']" +FIRST_TREE = By.CSS_SELECTOR,"[data-test='@web/ProductCard/body']" +ADD_TO_CART = By.CSS_SELECTOR,"[aria-label*='Artificial Christmas Tree Holiday Decor with 450']" +VIEW_CART = By.CSS_SELECTOR,"[href='/cart']" + + + @when('Click on Categories') def click_categories(context): - context.driver.find_element(By.CSS_SELECTOR, "[aria-label='Categories']").click() - sleep(2) + context.driver.wait.until(EC.element_to_be_clickable(CLICK_CATEGORIES)).click() @when('Click on Christmas button') def click_christmas(context): - context.driver.find_element(By.CSS_SELECTOR, "[data-url='/c/christmas/-/N-5xt30']").click() - sleep(2) + context.driver.find_element(*CLICK_CHRISTMAS).click() + @when('Click on Christmas Deals') def click_christmas_deals(context): - context.driver.find_element(By.CSS_SELECTOR,"[data-url='/c/christmas-deals/-/N-4rr05']").click() - sleep(2) + context.driver.find_element(*CLICK_DEALS).click() + @when('Click on Christmas Trees') def click_christmas_trees(context): - context.driver.find_element(By.CSS_SELECTOR,"[src='https://target.scene7.com/is/image/Target/GUEST_5ea06363-e13a-4069-8469-cd7cbf892955?wid=315&hei=315&qlt=60&fmt=webp']").click() - sleep(5) + context.driver.find_element(*CLICK_TREES).click() + @when('Click on first christmas tree') def click_first_tree(context): - context.driver.find_element(By.CSS_SELECTOR,"[data-test='@web/ProductCard/body']").click() - sleep(5) + context.driver.find_element(*FIRST_TREE).click() + @when('Click on Add to cart') def click_add_to_cart(context): - context.driver.find_element(By.CSS_SELECTOR,"[aria-label*='Artificial Christmas Tree Holiday Decor with 450']").click() - sleep(5) + context.driver.wait.until(EC.element_to_be_clickable(ADD_TO_CART)).click() @when('Click on view cart and checkout button') def view_cart(context): - context.driver.find_element(By.CSS_SELECTOR,"[href='/cart']").click() - sleep(3) + context.driver.find_element(*VIEW_CART).click() @then('Verify if result is shown') diff --git a/features/steps/target circle steps.py b/features/steps/target circle steps.py index 58c77f64..cd776c13 100644 --- a/features/steps/target circle steps.py +++ b/features/steps/target circle steps.py @@ -1,16 +1,18 @@ from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions as EC from behave import given, when, then from time import sleep + + @when('Click on Target Circle button') def search_circle(context): - context.driver.find_element(By.CSS_SELECTOR,"#utilityNav-circle").click() -sleep(5) + context.driver.wait.until(EC.element_to_be_clickable(*SEARCH_CIRCLE)).click() @then('Verify at least 10 cells present') def results_for_circle(context): - actual_results_circle = context.driver.find_elements(By.CSS_SELECTOR, "[data-test='@web/slingshot-components/CellsComponent/Link']") + actual_results_circle = context.driver.find_elements(*RESULTS) print(actual_results_circle) assert len(actual_results_circle) >= 10,f'Expected 10 links, but got {len(actual_results_circle)}' diff --git a/features/tests/Product colors .feature b/features/tests/Product colors .feature new file mode 100644 index 00000000..b5239f7f --- /dev/null +++ b/features/tests/Product colors .feature @@ -0,0 +1,7 @@ + +Feature: Searching for different colors of a product + + + Scenario: Use can click on different colors of a product + Given a specific product + Then Verify if product with specific color is displayed diff --git a/sample_script.py b/sample_script.py index 096f59ea..41d1f882 100755 --- a/sample_script.py +++ b/sample_script.py @@ -11,6 +11,7 @@ service = Service(driver_path) driver = webdriver.Chrome(service=service) driver.maximize_window() +driver.implicitly_wait(3) # open the url driver.get('https://www.google.com/') From f5cbe7e7479d46269934cade2dea5eaedb9f04d6 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Sun, 29 Dec 2024 15:34:02 -0500 Subject: [PATCH 12/19] Lesson 6 Homework --- Pages/base_page.py | 4 --- Pages/cart_empty.py | 18 ++++++++++++++ Pages/cart_page.py | 5 ---- Pages/circle_page.py | 16 ------------ Pages/header.py | 14 +++++++++++ Pages/search_results_page.py | 9 +++++++ features/steps/cart_empty.py | 19 ++++++++++++++ features/steps/product page target.py | 33 +++++++++++++++++++++++++ features/tests/airpods example .feature | 6 +++++ features/tests/cart_empty.feature | 6 +++++ 10 files changed, 105 insertions(+), 25 deletions(-) create mode 100644 Pages/cart_empty.py delete mode 100644 Pages/cart_page.py delete mode 100644 Pages/circle_page.py create mode 100644 Pages/header.py create mode 100644 Pages/search_results_page.py create mode 100644 features/steps/cart_empty.py create mode 100644 features/steps/product page target.py create mode 100644 features/tests/airpods example .feature create mode 100644 features/tests/cart_empty.feature diff --git a/Pages/base_page.py b/Pages/base_page.py index 40f18ca3..afcf1491 100644 --- a/Pages/base_page.py +++ b/Pages/base_page.py @@ -4,18 +4,14 @@ class BasePage: def __init__(self, driver): self.driver = driver - def open_url(self,url): self.driver.get(url) - def click(self,*locator): self.driver.find_element(*locator).click() - def find_element(self,*locator): return self.driver.find_element(*locator) - def input_text(self,text,*locator): self.driver.find_element(*locator).send_keys(text) diff --git a/Pages/cart_empty.py b/Pages/cart_empty.py new file mode 100644 index 00000000..f6992af0 --- /dev/null +++ b/Pages/cart_empty.py @@ -0,0 +1,18 @@ +from selenium.webdriver.common.by import By +from time import sleep +from Pages.base_page import BasePage + +class Cart(BasePage): + CART_ICON = By.CSS_SELECTOR,"div[data-test='@web/CartIcon']" + MESSAGE = By.CSS_SELECTOR,"div[data-test='boxEmptyMsg']" + + def click_cart(self,*locator): + self.click(*self.CART_ICON) + sleep(5) + + def verify_message(self,*locator): + self.find_element(*self.MESSAGE) + + + + diff --git a/Pages/cart_page.py b/Pages/cart_page.py deleted file mode 100644 index 1233624b..00000000 --- a/Pages/cart_page.py +++ /dev/null @@ -1,5 +0,0 @@ -from pages.base_page import Basepage - -class CartPage(Basepage): - def click_cart(self): - self.click_categories \ No newline at end of file diff --git a/Pages/circle_page.py b/Pages/circle_page.py deleted file mode 100644 index dfb03add..00000000 --- a/Pages/circle_page.py +++ /dev/null @@ -1,16 +0,0 @@ -from selenium.webdriver.common.by import By -from Pages.base_page import BasePage - -SEARCH_CIRCLE = By.CSS_SELECTOR,"#utilityNav-circle" -RESULTS = By.CSS_SELECTOR, "[data-test='@web/slingshot-components/CellsComponent/Link']" - -class CirclePage(BasePage): - - def click_circle_button(self): - self.click(self,*SEARCH_CIRCLE) - - def find_element(self,*RESULTS): - print('Searching by {*RESULTS}') - - - diff --git a/Pages/header.py b/Pages/header.py new file mode 100644 index 00000000..971d0b6e --- /dev/null +++ b/Pages/header.py @@ -0,0 +1,14 @@ +from selenium.webdriver import Keys + +from Pages.base_page import BasePage +from selenium.webdriver.common.by import By +from time import sleep + +class HeaderPage(BasePage): + SEARCH_BAR=By.CSS_SELECTOR, "[data-test='@web/Search/SearchInput']" + SEARCH_BTN=By.CSS_SELECTOR, "[data-test='@web/Search/SearchButton']" + + def search_bar(self,product,*locator): + self.input_text(product,*self.SEARCH_BAR).send_keys(product) + self.click(*self.SEARCH_BTN) + sleep(10) diff --git a/Pages/search_results_page.py b/Pages/search_results_page.py new file mode 100644 index 00000000..5ebb9dc6 --- /dev/null +++ b/Pages/search_results_page.py @@ -0,0 +1,9 @@ +from selenium.webdriver.common.by import By +from Pages.base_page import BasePage + +class SearchResultsPage(BasePage): + SEARCH_RESULT=By.CSS_SELECTOR, "[data-test='resultsHeading']" + + def verify_search_results(self,product): + actual_result = self.find_element(*self.SEARCH_RESULT).text + assert product in actual_result, f'Expected result {product} not in {actual_result}' \ No newline at end of file diff --git a/features/steps/cart_empty.py b/features/steps/cart_empty.py new file mode 100644 index 00000000..0d6ab35c --- /dev/null +++ b/features/steps/cart_empty.py @@ -0,0 +1,19 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then +from time import sleep + +@given("Target main page") +def target_main_page(context): + context.driver.get("https://www.target.com/") + + +@when("Click on Cart icon") +def click_cart_icon(context): + context.driver.find_element(By.CSS_SELECTOR,"div[data-test='@web/CartIcon']").click() + +@then("Verify “Your cart is empty” message is shown") +def verify_cart_empty(context): + expected_text = "Your cart is empty" + actual_result = context.driver.find_element(By.CSS_SELECTOR,"div[data-test='boxEmptyMsg']").text + assert expected_text in actual_result,f'{expected_text} not in {actual_result}' + diff --git a/features/steps/product page target.py b/features/steps/product page target.py new file mode 100644 index 00000000..17dd62b1 --- /dev/null +++ b/features/steps/product page target.py @@ -0,0 +1,33 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then +from time import sleep + + + +LISTINGS = (By.CSS_SELECTOR, "[data-test*='@web/site-top-of-funnel/ProductCardWrapper']") +PRODUCT_TITLE = (By.CSS_SELECTOR, "[data-test='product-title']") +PRODUCT_IMG = (By.CSS_SELECTOR, 'img') + +@given('Open Target product page') +def open_product_page(context): + context.driver.get('https://www.target.com/c/laundry-care-household-essentials/all-deals/-/N-5xsyrZakkos') + sleep(4) + + +@then('Verify that every product has a name and an image') +def verify_products_name_img(context): + # To see ALL listings (comment out if you only check top ones): + context.driver.execute_script("window.scrollBy(0,2000)", "") + sleep(4) + context.driver.execute_script("window.scrollBy(0,2000)", "") + + # Find all products: + all_products = context.driver.find_elements(*LISTINGS) + # print(all_products) + assert len(all_products) > 0, 'No products found' + + for product in all_products: + title = product.find_element(*PRODUCT_TITLE).text + assert title, 'Product title not shown' + print(title) + product.find_element(*PRODUCT_IMG) diff --git a/features/tests/airpods example .feature b/features/tests/airpods example .feature new file mode 100644 index 00000000..82ac2dbb --- /dev/null +++ b/features/tests/airpods example .feature @@ -0,0 +1,6 @@ + +Feature: Target product page + + Scenario: Verify that user can see product names and images + Given Open target product page + Then Verify that every product has a name and an image \ No newline at end of file diff --git a/features/tests/cart_empty.feature b/features/tests/cart_empty.feature new file mode 100644 index 00000000..8cea81cc --- /dev/null +++ b/features/tests/cart_empty.feature @@ -0,0 +1,6 @@ +Feature: Cart Empty + +Scenario: “Your cart is empty” message is shown for empty cart + Given Target main page + When Click on Cart icon + Then Verify “Your cart is empty” message is shown From 4060bcc2d4cbb8f6112b73eb9cd6738fe3168440 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Sun, 29 Dec 2024 15:43:42 -0500 Subject: [PATCH 13/19] Updated HW lesson 6 --- Application/application.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Application/application.py b/Application/application.py index 23c9b7b5..8549657f 100644 --- a/Application/application.py +++ b/Application/application.py @@ -1,8 +1,8 @@ -from pages.base_page import BasePage -from pages.Main_page import MainPage -from pages.circle_page import CirclePage -from pages.cart_page import CartPage - +from Pages.base_page import BasePage +from Pages.Main_page import MainPage +from Pages.header import HeaderPage +from Pages.cart_empty import Cart +from Pages.search_results_page import SearchResultsPage from locators import driver @@ -11,14 +11,17 @@ def __init__(self, driver): self.driver = driver self.base_page=BasePage(driver) self.main_page=MainPage(driver) - self.circle_page=CirclePage(driver) - self.cart_page=CartPage(driver) + self.header_page=HeaderPage(driver) + self.search_results_page=SearchResultsPage(driver) + self.cart=Cart(driver) app=Application(driver) app.base_page.function -app.main_page.function -app.circle_page.function -app.cart_page.function +app.Main_page.function +app.header.function +app.cart_empty.function +app.search_results_page.function + From f59254c3809a00f69d1b82c37f31ef7e199481aa Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Wed, 8 Jan 2025 15:13:18 -0500 Subject: [PATCH 14/19] updated lesson 6 HW --- Pages/base_page.py | 48 +++++++++++++++++++++++++++++ Pages/header.py | 17 ++++++++++ features/steps/cart_empty.py | 6 ++-- features/steps/sign into account.py | 18 +++++++++++ features/steps/target search.py | 8 ++--- features/tests/sign in .feature | 8 +++++ 6 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 features/steps/sign into account.py create mode 100644 features/tests/sign in .feature diff --git a/Pages/base_page.py b/Pages/base_page.py index afcf1491..e01f7918 100644 --- a/Pages/base_page.py +++ b/Pages/base_page.py @@ -1,12 +1,20 @@ +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC + + class BasePage: def __init__(self, driver): self.driver = driver + self.wait = WebDriverWait(driver, 15) def open_url(self,url): self.driver.get(url) + def get_url(self): + return self.driver.current_url + def click(self,*locator): self.driver.find_element(*locator).click() @@ -15,3 +23,43 @@ def find_element(self,*locator): def input_text(self,text,*locator): self.driver.find_element(*locator).send_keys(text) + + def wait_for_element_visible(self, *locator): + return self.wait.until( + EC.visibility_of_element_located(locator), + message=f'Element by {locator} not visible' + ) + + def wait_for_element_invisible(self, *locator): + self.wait.until( + EC.invisibility_of_element_located(locator), + message=f'Element by {locator} should not be visible' + ) + + def wait_for_element_clickable(self, *locator): + return self.wait.until( + EC.element_to_be_clickable(locator), + message=f'Element by {locator} not clickable' + ) + + def wait_and_click(self, *locator): + self.wait.until( + EC.element_to_be_clickable(locator), + message=f'Element by {locator} not clickable' + ).click() + + def verify_partial_text(self, expected_text, *locator): + actual_text = self.find_element(*locator).text + assert expected_text in actual_text, f'Expected {expected_text} not in actual {actual_text}' + + def verify_text(self, expected_text, *locator): + actual_text = self.find_element(*locator).text + assert expected_text == actual_text, f'Expected {expected_text}, but got {actual_text}' + + def verify_partial_url(self, expected_url): + actual_url = self.driver.current_url + assert expected_url in actual_url, f'Expected partial url {expected_url} not in actual {actual_url}' + + def verify_url(self, expected_url): + actual_url = self.driver.current_url + assert expected_url == actual_url, f'Expected url {expected_url} does not match actual {actual_url}' diff --git a/Pages/header.py b/Pages/header.py index 971d0b6e..831323e8 100644 --- a/Pages/header.py +++ b/Pages/header.py @@ -5,10 +5,27 @@ from time import sleep class HeaderPage(BasePage): + SEARCH_BAR=By.CSS_SELECTOR, "[data-test='@web/Search/SearchInput']" SEARCH_BTN=By.CSS_SELECTOR, "[data-test='@web/Search/SearchButton']" + SIGN_IN_BUTTON = By.CSS_SELECTOR,"[aria-label='Account, sign in']" + SIDE_NAV_SIGN_IN = By.CSS_SELECTOR,"[data-test='accountNav-signIn']" + SIGN_IN_MESSAGE = By.CSS_SELECTOR, "//span[text()='Sign into your Target account']" def search_bar(self,product,*locator): self.input_text(product,*self.SEARCH_BAR).send_keys(product) self.click(*self.SEARCH_BTN) sleep(10) + + def sign_in(self,*locator): + self.click(*self.SIGN_IN_BUTTON) + sleep(5) + + def side_nav_sign_in(self,*locator): + self.click(*self.SIDE_NAV_SIGN_IN) + sleep(5) + + def verify_sign_in_page(self): + self.verify_text('Sign into your Target account',*self.SIGN_IN_MESSAGE) + + diff --git a/features/steps/cart_empty.py b/features/steps/cart_empty.py index 0d6ab35c..8a788bbb 100644 --- a/features/steps/cart_empty.py +++ b/features/steps/cart_empty.py @@ -4,16 +4,16 @@ @given("Target main page") def target_main_page(context): - context.driver.get("https://www.target.com/") + context.app.Main_page.open_target() @when("Click on Cart icon") def click_cart_icon(context): - context.driver.find_element(By.CSS_SELECTOR,"div[data-test='@web/CartIcon']").click() + context.app.header.click_cart_icon().click() @then("Verify “Your cart is empty” message is shown") def verify_cart_empty(context): expected_text = "Your cart is empty" actual_result = context.driver.find_element(By.CSS_SELECTOR,"div[data-test='boxEmptyMsg']").text assert expected_text in actual_result,f'{expected_text} not in {actual_result}' - + context.app.cart_empty.verify_cart_empty(actual_result) diff --git a/features/steps/sign into account.py b/features/steps/sign into account.py new file mode 100644 index 00000000..130317f9 --- /dev/null +++ b/features/steps/sign into account.py @@ -0,0 +1,18 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then + + +@when('user clicks on sign in button') +def sign_in(context): + context.app.header.sign_in.click() + +@when('user clicks on side navigation side in button') +def side_navigation(context): + context.app.header.side_navigation.click() + +@then('Verify if Sign in message is displayed') +def verify_sign_in(context): + expected_message = 'Sign into your Target account' + actual_result = context.driver.find_element(By.CSS_SELECTOR,"//span[text()='Sign into your Target account']") + assert expected_message == actual_result, f'{expected_message} != {actual_result}' + context.app.header.verify_sign_in() \ No newline at end of file diff --git a/features/steps/target search.py b/features/steps/target search.py index 00436455..9d5423a8 100644 --- a/features/steps/target search.py +++ b/features/steps/target search.py @@ -5,24 +5,24 @@ @given('Open Target page') def open_target(context): - context.driver.get('https://www.target.com') + context.app.Main_page.open_target() sleep(3) @when('search for a {product}') def search_product(context, product): context.driver.find_element(By.CSS_SELECTOR, "[data-test='@web/Search/SearchInput']").send_keys(product) - sleep(1) context.driver.find_element(By.CSS_SELECTOR, "[data-test='@web/Search/SearchButton']").click() - sleep(3) + sleep(10) + context.app.header.search_product(product) @then('verify search for results are shown for {product}') def results_for_product(context,product): actual_result = context.driver.find_element(By.CSS_SELECTOR, "[data-test='resultsHeading']").text - assert product in actual_result,f'Expected result {product} not in {actual_result}' sleep(3) + context.app.search_results_page.results_for_product(product) diff --git a/features/tests/sign in .feature b/features/tests/sign in .feature new file mode 100644 index 00000000..67e2cfcb --- /dev/null +++ b/features/tests/sign in .feature @@ -0,0 +1,8 @@ + +Feature: Logged out user can sign in + + Scenario: User can sign into target account + Given Target main page + When user clicks on sign in button + When user clicks on side navigation side in button + Then Verify if Sign in message is displayed From 372ee9d4d833a35db16334a306bc7fb6b93ca249 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Fri, 10 Jan 2025 09:12:57 -0500 Subject: [PATCH 15/19] Homework for lesson 6 --- Application/application.py | 4 ++-- features/environment.py | 3 ++- features/steps/cart_empty.py | 7 ++----- features/steps/target search.py | 6 +++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Application/application.py b/Application/application.py index 8549657f..bfc33991 100644 --- a/Application/application.py +++ b/Application/application.py @@ -10,10 +10,10 @@ class Application: def __init__(self, driver): self.driver = driver self.base_page=BasePage(driver) - self.main_page=MainPage(driver) + self.Main_page=MainPage(driver) self.header_page=HeaderPage(driver) self.search_results_page=SearchResultsPage(driver) - self.cart=Cart(driver) + self.cart_empty=Cart(driver) app=Application(driver) app.base_page.function diff --git a/features/environment.py b/features/environment.py index 6f0a2984..64ffbd20 100755 --- a/features/environment.py +++ b/features/environment.py @@ -2,7 +2,8 @@ from selenium.webdriver.chrome.service import Service from selenium.webdriver.support.wait import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager -from app.application import Application +from Application.application import Application + diff --git a/features/steps/cart_empty.py b/features/steps/cart_empty.py index 8a788bbb..74c2cc8d 100644 --- a/features/steps/cart_empty.py +++ b/features/steps/cart_empty.py @@ -2,18 +2,15 @@ from behave import given, when, then from time import sleep -@given("Target main page") -def target_main_page(context): - context.app.Main_page.open_target() @when("Click on Cart icon") def click_cart_icon(context): - context.app.header.click_cart_icon().click() + context.app.cart_empty.click_cart.click() @then("Verify “Your cart is empty” message is shown") def verify_cart_empty(context): expected_text = "Your cart is empty" actual_result = context.driver.find_element(By.CSS_SELECTOR,"div[data-test='boxEmptyMsg']").text assert expected_text in actual_result,f'{expected_text} not in {actual_result}' - context.app.cart_empty.verify_cart_empty(actual_result) + context.app.cart_empty.verify_message(actual_result) diff --git a/features/steps/target search.py b/features/steps/target search.py index 9d5423a8..fc456c5e 100644 --- a/features/steps/target search.py +++ b/features/steps/target search.py @@ -5,7 +5,7 @@ @given('Open Target page') def open_target(context): - context.app.Main_page.open_target() + context.app.Main_page.open_main_page() sleep(3) @@ -14,7 +14,7 @@ def search_product(context, product): context.driver.find_element(By.CSS_SELECTOR, "[data-test='@web/Search/SearchInput']").send_keys(product) context.driver.find_element(By.CSS_SELECTOR, "[data-test='@web/Search/SearchButton']").click() sleep(10) - context.app.header.search_product(product) + context.app.header.search_bar(product) @then('verify search for results are shown for {product}') @@ -22,7 +22,7 @@ def results_for_product(context,product): actual_result = context.driver.find_element(By.CSS_SELECTOR, "[data-test='resultsHeading']").text assert product in actual_result,f'Expected result {product} not in {actual_result}' sleep(3) - context.app.search_results_page.results_for_product(product) + context.app.search_results_page.verify_search_results(product) From 59ee9857f9a2f563cd014aa92b61a9671eb02a76 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Fri, 17 Jan 2025 11:23:22 -0500 Subject: [PATCH 16/19] Homework lesson 7 --- Application/application.py | 12 +++---- Pages/{cart_empty.py => cart_messages.py} | 6 ++++ Pages/chips_page.py | 10 ++++++ Pages/header.py | 38 +++++++++++++++++++- features/steps/add product to cart steps.py | 34 ++++++++++++++++++ features/steps/sign into account.py | 9 ++--- features/tests/Add products to cart .feature | 13 +++++++ features/tests/cart_empty.feature | 2 +- 8 files changed, 109 insertions(+), 15 deletions(-) rename Pages/{cart_empty.py => cart_messages.py} (73%) create mode 100644 Pages/chips_page.py create mode 100644 features/steps/add product to cart steps.py create mode 100644 features/tests/Add products to cart .feature diff --git a/Application/application.py b/Application/application.py index bfc33991..27e67ff6 100644 --- a/Application/application.py +++ b/Application/application.py @@ -1,8 +1,9 @@ from Pages.base_page import BasePage from Pages.Main_page import MainPage from Pages.header import HeaderPage -from Pages.cart_empty import Cart +from Pages.cart_messages import Cart from Pages.search_results_page import SearchResultsPage +from Pages.chips_page import ChipsPage from locators import driver @@ -13,14 +14,11 @@ def __init__(self, driver): self.Main_page=MainPage(driver) self.header_page=HeaderPage(driver) self.search_results_page=SearchResultsPage(driver) - self.cart_empty=Cart(driver) + self.cart_messages=Cart(driver) + self.chips_page = ChipsPage(driver) app=Application(driver) -app.base_page.function -app.Main_page.function -app.header.function -app.cart_empty.function -app.search_results_page.function + diff --git a/Pages/cart_empty.py b/Pages/cart_messages.py similarity index 73% rename from Pages/cart_empty.py rename to Pages/cart_messages.py index f6992af0..ca81945d 100644 --- a/Pages/cart_empty.py +++ b/Pages/cart_messages.py @@ -5,6 +5,7 @@ class Cart(BasePage): CART_ICON = By.CSS_SELECTOR,"div[data-test='@web/CartIcon']" MESSAGE = By.CSS_SELECTOR,"div[data-test='boxEmptyMsg']" + PRODUCT_IN_CART = By.XPATH, "//span[text()='$6.69 subtotal']" def click_cart(self,*locator): self.click(*self.CART_ICON) @@ -13,6 +14,11 @@ def click_cart(self,*locator): def verify_message(self,*locator): self.find_element(*self.MESSAGE) + def product_in_cart(self,*locator): + self.find_element(*self.PRODUCT_IN_CART) + + + diff --git a/Pages/chips_page.py b/Pages/chips_page.py new file mode 100644 index 00000000..b9f590c9 --- /dev/null +++ b/Pages/chips_page.py @@ -0,0 +1,10 @@ +from Pages.base_page import BasePage +from selenium.webdriver.common.by import By +from time import sleep + +class ChipsPage(BasePage): + + ADD_TO_CART_ON_CHIPS_PAGE = By.CSS_SELECTOR, "[aria-label='Add Doritos Nacho Cheese Flavor Party Size Tortilla Chips - 14.5oz to cart']" + +def click_add_to_cart(self ,*locator): + self.click(*self.ADD_TO_CART_ON_CHIPS_PAGE) \ No newline at end of file diff --git a/Pages/header.py b/Pages/header.py index 831323e8..e3fb8da0 100644 --- a/Pages/header.py +++ b/Pages/header.py @@ -11,21 +11,57 @@ class HeaderPage(BasePage): SIGN_IN_BUTTON = By.CSS_SELECTOR,"[aria-label='Account, sign in']" SIDE_NAV_SIGN_IN = By.CSS_SELECTOR,"[data-test='accountNav-signIn']" SIGN_IN_MESSAGE = By.CSS_SELECTOR, "//span[text()='Sign into your Target account']" + CATEGORIES_BTN =By.CSS_SELECTOR,"[aria-label='Categories']" + GROCERY_BTN = By.CSS_SELECTOR,"[data-url='/c/grocery/-/N-5xt1a']" + SNACK_BTN = By.CSS_SELECTOR,"[data-url='/c/snacks-grocery/-/N-5xsy9']" + CHIPS_BTN = By.CSS_SELECTOR, "[data-url='/c/chips-snacks-grocery/-/N-5xsy7']" + ADD_TO_CART_SIDE_NAV_PAGE = By.CSS_SELECTOR, "[data-test='orderPickupButton']" + VIEW_CART = By.CSS_SELECTOR, "[href='/cart']" + + def click_category(self,*locator): + self.click(*self.CATEGORIES_BTN) + + + def click_grocery(self,*locator): + self.click(*self.GROCERY_BTN) + + + def click_snacks(self,*locator): + self.click(*self.SNACK_BTN) + + + def click_chips(self,*locator): + self.click(*self.CHIPS_BTN) + + + def click_add_to_side(self,*locator): + self.click(*self.ADD_TO_CART_SIDE_NAV_PAGE) + + + def click_view_cart(self,*locator): + self.click(*self.VIEW_CART) + def search_bar(self,product,*locator): self.input_text(product,*self.SEARCH_BAR).send_keys(product) self.click(*self.SEARCH_BTN) sleep(10) + def sign_in(self,*locator): self.click(*self.SIGN_IN_BUTTON) sleep(5) + def side_nav_sign_in(self,*locator): self.click(*self.SIDE_NAV_SIGN_IN) sleep(5) - def verify_sign_in_page(self): + + def verify_sign_in_page(self,expected_text,*locator): self.verify_text('Sign into your Target account',*self.SIGN_IN_MESSAGE) + + + diff --git a/features/steps/add product to cart steps.py b/features/steps/add product to cart steps.py new file mode 100644 index 00000000..79dddce4 --- /dev/null +++ b/features/steps/add product to cart steps.py @@ -0,0 +1,34 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then +from time import sleep + +@when("Click on Grocery") +def click_grocery(context): + context.app.header.click_grocery() + + +@when("Click on Snacks") +def click_snacks(context): + context.app.header.click_snacks() + + +@when("Click on Chips") +def click_chips(context): + context.app.header.click_chips() + + +@when("Click on Add to cart for Doritos") +def click_add_to_cart(context): + context.app.chips_page.click_add_to_cart() + + +@when("Click on Add to cart side nav") +def click_add_to_cart_side_nav(context): + context.app.header.click_add_to_side() + + +@then("Verify if {product} is shown") +def verify_product(context,product): + context.app.cart_messages.product_in_cart(product) + + diff --git a/features/steps/sign into account.py b/features/steps/sign into account.py index 130317f9..4e4d1f0a 100644 --- a/features/steps/sign into account.py +++ b/features/steps/sign into account.py @@ -4,15 +4,12 @@ @when('user clicks on sign in button') def sign_in(context): - context.app.header.sign_in.click() + context.app.header.sign_in() @when('user clicks on side navigation side in button') def side_navigation(context): - context.app.header.side_navigation.click() + context.app.header.side_nav_sign_in() @then('Verify if Sign in message is displayed') def verify_sign_in(context): - expected_message = 'Sign into your Target account' - actual_result = context.driver.find_element(By.CSS_SELECTOR,"//span[text()='Sign into your Target account']") - assert expected_message == actual_result, f'{expected_message} != {actual_result}' - context.app.header.verify_sign_in() \ No newline at end of file + context.app.header.verify_sign_in_page() \ No newline at end of file diff --git a/features/tests/Add products to cart .feature b/features/tests/Add products to cart .feature new file mode 100644 index 00000000..71385977 --- /dev/null +++ b/features/tests/Add products to cart .feature @@ -0,0 +1,13 @@ + +Feature: Adding a product to cart + + Scenario: User will be able to add a product into their cart + Given Open Target page + When Click on Categories + When Click on Grocery + When Click on Snacks + When Click on Chips + When Click on Add to cart for Doritos + When Click on Add to cart side nav + When Click on view cart and checkout button + Then Verify if {product} is shown diff --git a/features/tests/cart_empty.feature b/features/tests/cart_empty.feature index 8cea81cc..0b51e644 100644 --- a/features/tests/cart_empty.feature +++ b/features/tests/cart_empty.feature @@ -1,6 +1,6 @@ Feature: Cart Empty Scenario: “Your cart is empty” message is shown for empty cart - Given Target main page + Given Open Target page When Click on Cart icon Then Verify “Your cart is empty” message is shown From 21c2a41eea53d3aea9e4aea328cb34851da96d9b Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Mon, 17 Mar 2025 09:17:41 -0400 Subject: [PATCH 17/19] test --- Application/application.py | 2 ++ Pages/Sign_in.py | 6 ++++++ Pages/base_page.py | 6 +++--- README.md | 2 ++ features/steps/sign in steps.py | 4 ++++ features/tests/window handling test case .feature | 9 +++++++++ 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 Pages/Sign_in.py create mode 100644 features/steps/sign in steps.py create mode 100644 features/tests/window handling test case .feature diff --git a/Application/application.py b/Application/application.py index 27e67ff6..b3d9c5c0 100644 --- a/Application/application.py +++ b/Application/application.py @@ -4,6 +4,7 @@ from Pages.cart_messages import Cart from Pages.search_results_page import SearchResultsPage from Pages.chips_page import ChipsPage +from Pages.Sign_in import SignPage from locators import driver @@ -16,6 +17,7 @@ def __init__(self, driver): self.search_results_page=SearchResultsPage(driver) self.cart_messages=Cart(driver) self.chips_page = ChipsPage(driver) + self.Sign_in=SignPage(driver) app=Application(driver) diff --git a/Pages/Sign_in.py b/Pages/Sign_in.py new file mode 100644 index 00000000..af797db8 --- /dev/null +++ b/Pages/Sign_in.py @@ -0,0 +1,6 @@ +from Pages.base_page import BasePage +from selenium.webdriver.common.by import By +from time import sleep + +class SignPage(BasePage): + diff --git a/Pages/base_page.py b/Pages/base_page.py index e01f7918..70ec4cba 100644 --- a/Pages/base_page.py +++ b/Pages/base_page.py @@ -24,19 +24,19 @@ def find_element(self,*locator): def input_text(self,text,*locator): self.driver.find_element(*locator).send_keys(text) - def wait_for_element_visible(self, *locator): + def wait_for_element_visible(self, locator): return self.wait.until( EC.visibility_of_element_located(locator), message=f'Element by {locator} not visible' ) - def wait_for_element_invisible(self, *locator): + def wait_for_element_invisible(self, locator): self.wait.until( EC.invisibility_of_element_located(locator), message=f'Element by {locator} should not be visible' ) - def wait_for_element_clickable(self, *locator): + def wait_for_element_clickable(self, locator): return self.wait.until( EC.element_to_be_clickable(locator), message=f'Element by {locator} not clickable' diff --git a/README.md b/README.md index 581349c3..dfde9609 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ written in ### Python 3, Behave https://www.careerist.com/automation + +poop diff --git a/features/steps/sign in steps.py b/features/steps/sign in steps.py new file mode 100644 index 00000000..a6033fd0 --- /dev/null +++ b/features/steps/sign in steps.py @@ -0,0 +1,4 @@ +from selenium.webdriver.common.by import By +from behave import given, when, then + +@when('Open sign in page') diff --git a/features/tests/window handling test case .feature b/features/tests/window handling test case .feature new file mode 100644 index 00000000..460da3a8 --- /dev/null +++ b/features/tests/window handling test case .feature @@ -0,0 +1,9 @@ +Feature: Window Handling test case + + Scenario: User can open and close Terms and Conditions from sign in page + Given Open sign in page + When Store original window + And Click on Target terms and conditions link + And Switch to the newly opened window + Then Verify Terms and Conditions page is opened + And User can close new window and switch back to original \ No newline at end of file From 7897786f7bc5427e1ce6d42d5659f5d196ce53a1 Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Thu, 10 Apr 2025 18:22:06 -0400 Subject: [PATCH 18/19] Update file --- Application/application.py | 6 +- PP.txt | 7 ++ Pages/Sign_in.py | 6 -- Pages/base_page.py | 18 ++++ Pages/sign_in.py | 23 +++++ Pages/terms_conditions_page.py | 10 ++ features/environment.py | 41 +++++--- features/steps/cart_empty.py | 1 - features/steps/sign in steps.py | 34 ++++++- features/tests/window handling .feature | 12 +++ python coding practice and review .py | 122 ++++++++++++++++++++++++ python practice.py | 2 + python.py => python/__init__.py | 0 walmart practice coding.py | 4 + 14 files changed, 264 insertions(+), 22 deletions(-) delete mode 100644 Pages/Sign_in.py create mode 100644 Pages/sign_in.py create mode 100644 Pages/terms_conditions_page.py create mode 100644 features/tests/window handling .feature create mode 100644 python coding practice and review .py create mode 100644 python practice.py rename python.py => python/__init__.py (100%) create mode 100644 walmart practice coding.py diff --git a/Application/application.py b/Application/application.py index b3d9c5c0..f2b8285b 100644 --- a/Application/application.py +++ b/Application/application.py @@ -4,7 +4,8 @@ from Pages.cart_messages import Cart from Pages.search_results_page import SearchResultsPage from Pages.chips_page import ChipsPage -from Pages.Sign_in import SignPage +from Pages.sign_in import SignPage +from Pages.terms_conditions_page import TermsConditionsPage from locators import driver @@ -17,7 +18,8 @@ def __init__(self, driver): self.search_results_page=SearchResultsPage(driver) self.cart_messages=Cart(driver) self.chips_page = ChipsPage(driver) - self.Sign_in=SignPage(driver) + self.sign_in=SignPage(driver) + self.terms_conditions_page=TermsConditionsPage(driver) app=Application(driver) diff --git a/PP.txt b/PP.txt index e69de29b..81e60d93 100644 --- a/PP.txt +++ b/PP.txt @@ -0,0 +1,7 @@ +Year_born = str(input('Enter year born: ')) +Name = input('Enter your name: ') + +message = f'Hello, {Name}. You were born in the year {Year_born}.' +print(message) + + diff --git a/Pages/Sign_in.py b/Pages/Sign_in.py deleted file mode 100644 index af797db8..00000000 --- a/Pages/Sign_in.py +++ /dev/null @@ -1,6 +0,0 @@ -from Pages.base_page import BasePage -from selenium.webdriver.common.by import By -from time import sleep - -class SignPage(BasePage): - diff --git a/Pages/base_page.py b/Pages/base_page.py index 70ec4cba..486fd5ac 100644 --- a/Pages/base_page.py +++ b/Pages/base_page.py @@ -24,6 +24,21 @@ def find_element(self,*locator): def input_text(self,text,*locator): self.driver.find_element(*locator).send_keys(text) + def get_current_window_handle(self): + return self.driver.current_window_handle + + def switch_to_new_window(self): + self.wait.until(EC.new_window_is_opened()) + all_windows = self.driver.window_handles + print('All windows: ', all_windows) + self.driver.switch_to.window(all_windows[1]) + print('Current window: ', self.driver.current_window_handle) + + def switch_to_original_window(self,window_id): + self.driver.switch_to.window(window_id) + print("Current Window: ", self.driver.current_window_handle) + + def wait_for_element_visible(self, locator): return self.wait.until( EC.visibility_of_element_located(locator), @@ -63,3 +78,6 @@ def verify_partial_url(self, expected_url): def verify_url(self, expected_url): actual_url = self.driver.current_url assert expected_url == actual_url, f'Expected url {expected_url} does not match actual {actual_url}' + + def close(self): + self.driver.close() diff --git a/Pages/sign_in.py b/Pages/sign_in.py new file mode 100644 index 00000000..a8c11bc7 --- /dev/null +++ b/Pages/sign_in.py @@ -0,0 +1,23 @@ +from Pages.base_page import BasePage +from selenium.webdriver.common.by import By +from time import sleep + + +class SignPage(BasePage): + Terms_conditions = (By.XPATH,"//a[contains(text(),'Terms')]") + + def open_sign_in(self): + self.open_url('https://www.target.com/login?client_id=ecom-web-1.0.0&ui_namespace=ui-default&back_button_action=browser&keep_me_signed_in=true&kmsi_default=false&actions=create_session_request_username') + + + def click_terms(self): + self.click(self.Terms_conditions) + + + def verify_terms_opened(self): + self.verify_partial_url('terms-conditions') + + + + + diff --git a/Pages/terms_conditions_page.py b/Pages/terms_conditions_page.py new file mode 100644 index 00000000..c0c0d3e4 --- /dev/null +++ b/Pages/terms_conditions_page.py @@ -0,0 +1,10 @@ +from Pages.base_page import BasePage +from selenium.webdriver.common.by import By +from time import sleep + +class TermsConditionsPage(BasePage): + + def verify_terms(self): + self.verify_partial_text('terms-conditions') + + diff --git a/features/environment.py b/features/environment.py index 64ffbd20..acf322d4 100755 --- a/features/environment.py +++ b/features/environment.py @@ -2,32 +2,49 @@ from selenium.webdriver.chrome.service import Service from selenium.webdriver.support.wait import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager -from Application.application import Application - +from app.application import Application +from webdriver_manager.firefox import GeckoDriverManager +from selenium.webdriver.chrome.options import Options def browser_init(context): - """ - :param context: Behave context - """ - driver_path = ChromeDriverManager().install() - service = Service(driver_path) - context.driver = webdriver.Chrome(service=service) + def browser_init(context, scenario_name): + """ + :param context: Behave context + """ + driver_path = ChromeDriverManager().install() + service = Service(driver_path) + context.driver = webdriver.Chrome(service=service) + - context.driver.maximize_window() - context.driver.implicitly_wait(5) context.driver.wait = WebDriverWait(context.driver, 15) context.app = Application(context.driver) - context.app.implicitly_wait(5) + ### BROWSERSTACK ### + # Register for BrowserStack, then grab it from https://www.browserstack.com/accounts/settings + bs_user = 'poojap_n58Du0' + bs_key = 'jFHNdxSxEVo9CJ5NkVsV' + url = f'http://{bs_user}:{bs_key}@hub-cloud.browserstack.com/wd/hub' + options = Options() + bstack_options = { + "os": "Windows", + "osVersion": "11", + 'browserName': 'edge', + 'sessionName': scenario_name, + } + options.set_capability('bstack:options', bstack_options) + context.driver = webdriver.Remote(command_executor=url, options=options) + + context.driver.maximize_window() + context.driver.implicitly_wait(5) def before_scenario(context, scenario): print('\nStarted scenario: ', scenario.name) browser_init(context) - + browser_init(context, scenario.name) def before_step(context, step): print('\nStarted step: ', step) diff --git a/features/steps/cart_empty.py b/features/steps/cart_empty.py index 74c2cc8d..585e798e 100644 --- a/features/steps/cart_empty.py +++ b/features/steps/cart_empty.py @@ -3,7 +3,6 @@ from time import sleep - @when("Click on Cart icon") def click_cart_icon(context): context.app.cart_empty.click_cart.click() diff --git a/features/steps/sign in steps.py b/features/steps/sign in steps.py index a6033fd0..327b9871 100644 --- a/features/steps/sign in steps.py +++ b/features/steps/sign in steps.py @@ -1,4 +1,36 @@ from selenium.webdriver.common.by import By from behave import given, when, then -@when('Open sign in page') + +@given('Open sign in page') +def open_sign_in_page(context): + context.app.sign_in.open_sign_in() + +@when('Store original window') +def store_original_window(context): + context.original_window= context.app.sign_in.get_current_window_handle() + +@when('Click on Target terms and conditions link') +def click_target_terms_and_conditions(context): + context.app.sign_in.click_terms() + +@when('Switch to the newly opened window') +def switch_to_newly_opened_window(context): + context.app.sign_in.switch_to.window(context.driver.window_handle[1]) + +@then('Verify Terms and Conditions page is opened') +def verify_terms_and_conditions_page(context): + context.app.terms_conditions_page.verify_terms() + +@then('User can close new window') +def user_close_new_window(context): + context.app.terms_conditions_page.close() + +@then('switch back to original') +def switch_to_original_window(context): + context.app.sign_in.switch_to_original_window(context.original_window) + + + + + diff --git a/features/tests/window handling .feature b/features/tests/window handling .feature new file mode 100644 index 00000000..6e85ca2f --- /dev/null +++ b/features/tests/window handling .feature @@ -0,0 +1,12 @@ + + +Scenario: User can open and close Terms and Conditions from sign in page + Given Open sign in page + When Store original window + And Click on Target terms and conditions link + And Switch to the newly opened window + Then Verify Terms and Conditions page is opened + And User can close new window +`And switch back to original + + diff --git a/python coding practice and review .py b/python coding practice and review .py new file mode 100644 index 00000000..9081c5ed --- /dev/null +++ b/python coding practice and review .py @@ -0,0 +1,122 @@ + +#Lesson 2 on Numbers and Variables + #integer = whole nunmber 4 + #float = number with decimal point 4.5 + #floor division = counting the quotient using // symbol 9//2=4 + #remainder= remaining number after dividing: 6%4=2 + #exponentiation **, 6**2 = 36 + + #Variables + #Stores information that can be retrieved later on + #can be reassigned values + #cannot be a keyword + #cannot start with a number + #cannot contain spaces + #CAN have an underscore + #CAN have numbers within, just not to begin with + #are case sensitive + #Data Types + #Boolean= True or False values + #Dictionaries --> store multiple items of data as a list-- key:value pairs, values are referenced by key {'name':'Bob} + #Set--> restrictive python list w unique values separated by commas inside curly braces set = {'Alpha',"Bear'} + #string= type of text data type enclosed by quotes, string = 'Number of kids' + #List = allows us to store info in a specific order. We can add, remove, or modify elements after creating the list + #example, list = [1,2,3,4,5] + #Tuple--> a collection of elements which cannot be changed or reversed, represented by parenthesis + #tuple=(1,2,3,4,5) + +#Lesson 3: Strings + #enclosed within single '' or double "" quotes + #can contain letters, numbers, symbols, and even empty spaces + #triple quotes will break down string into multiple lines + #\n breaks code into a separate line + + #concatenation + #uses a + symbol to concatenate or join variables and text together + #Example: +Book ='Coding for Python' +copyright_year = 2002 +print("The book"+Book +"was written in" + str(copyright_year)) + +#.format() method +print('Hi there, {}'.format('Pooja')) +print("{0} and {1}".format('Pooja','Patel')) + +#F-strings + #Do not need to use + symbol or conversions +Age = 31 +Name= 'Pooja' +print(f'{Name} is {Age} years old.') +print(len(Name)) +print(str.upper(Name)) +print(str.lower(Name)) +print(str.count(Name,'oo')) +#str.replace('old','new')--> replacing variables +#str.count('letter')--> counts number of times something appears in a string + + +text = input('Enter the text to be formatted: ') +print("UPPERCASE:" + text.upper()) +print(text.lower()) +print(text.title()) +print(len(text)) + +sentence = input("Enter a sentence: ") +new_word = input("Enter the word to replace: ") +letter = input("Enter the letter to count: ") +print(sentence.replace(new_word, sentence)) +print(sentence.count(letter)) + + +#Slicing + #index--> refers to numerical position of an element within a string, uses square brackets [] to indicate index position + # indices can be positive or negative, starts with 0 from the left side and -1 on the right side +string = "Python" +print(string[0:3]) #--> regular string +print(string[-1:-3:-1]) #--> reversing a string + +sliced_sentence = 'Python programming is fun!' +print(sliced_sentence[7:18]) +print(sliced_sentence[0:25:3]) +print(sliced_sentence[::-1]) + + +#Lesson 4: Boolean + #data type that has only 2 possible values, True or False + #conditional operators + # < less than + # < = less than or equal to + # > greater than + # > = greater than or equal to + # == equal + # != does not equal + #If Statement = evaluates a given condition and if the condition is true, it executes a specific block of code + #Else Statement = executes other code when all other possibilities are false + # Elif Statement = another option to consider + #AND, OR, NOT = Boolean operators + +age = int(input('Enter your age:')) + +if age >= 18: + print('You are eligible to vote') +else: + print('You are not eligible to vote') + + +grade = int(input("Enter student’s grade: ")) + +if grade >= 90: + print('You\'ve got an A') +elif grade >= 80: + print('You\'ve got an B') +elif grade >= 70: + print('You\'ve got an C') +elif grade >= 60: + print('You\'ve got an D') +else: + print('You\'ve got an F') + +#Lesson on Lists: + # iterate means to walk over each + # first element of a list has an index of 0 + # lists are always declared using square brackets \ No newline at end of file diff --git a/python practice.py b/python practice.py new file mode 100644 index 00000000..139597f9 --- /dev/null +++ b/python practice.py @@ -0,0 +1,2 @@ + + diff --git a/python.py b/python/__init__.py similarity index 100% rename from python.py rename to python/__init__.py diff --git a/walmart practice coding.py b/walmart practice coding.py new file mode 100644 index 00000000..6f184c98 --- /dev/null +++ b/walmart practice coding.py @@ -0,0 +1,4 @@ +user_name = input("What's your name: ") + +def greet(user_name): + print("Hello," + user_name) From 474f3d5226bc62527f9459dead86433884a09f2b Mon Sep 17 00:00:00 2001 From: Pooja Patel Date: Mon, 21 Apr 2025 12:29:28 -0400 Subject: [PATCH 19/19] updated lesson 9 homework --- Application/application.py | 9 ++- CSS_selectors amazon.py | 27 --------- PP.txt | 7 --- Pages/base_page.py | 19 ++++--- Pages/help_page.py | 36 ++++++++++++ Pages/sign_in.py | 21 ++++++- Pages/target_help_page.py | 29 ++++++++++ features/environment.py | 56 +++++++++---------- features/steps/cart_empty.py | 1 + features/steps/product colors steps.py | 22 ++++---- features/steps/sign in steps.py | 32 +++++++++++ features/steps/target_help_steps.py | 24 ++++++++ features/tests/sign in .feature | 14 ++++- features/tests/target_help.feature | 10 ++++ .../tests/window handling test case .feature | 9 --- homework 2 | 18 ------ homework 2.py | 39 ------------- homework lesson 2.py | 27 --------- locators.py | 15 ----- python practice.py | 2 - requirements.txt | 4 -- target homework lesson 2.py | 27 --------- walmart practice coding.py | 4 -- 23 files changed, 221 insertions(+), 231 deletions(-) delete mode 100644 CSS_selectors amazon.py delete mode 100644 PP.txt create mode 100644 Pages/help_page.py create mode 100644 Pages/target_help_page.py create mode 100644 features/steps/target_help_steps.py create mode 100644 features/tests/target_help.feature delete mode 100644 features/tests/window handling test case .feature delete mode 100644 homework 2 delete mode 100644 homework 2.py delete mode 100644 homework lesson 2.py delete mode 100644 locators.py delete mode 100644 python practice.py delete mode 100755 requirements.txt delete mode 100644 target homework lesson 2.py delete mode 100644 walmart practice coding.py diff --git a/Application/application.py b/Application/application.py index f2b8285b..671280da 100644 --- a/Application/application.py +++ b/Application/application.py @@ -6,7 +6,9 @@ from Pages.chips_page import ChipsPage from Pages.sign_in import SignPage from Pages.terms_conditions_page import TermsConditionsPage -from locators import driver +from Pages.target_help_page import TargetHelpPage + + class Application: @@ -20,8 +22,11 @@ def __init__(self, driver): self.chips_page = ChipsPage(driver) self.sign_in=SignPage(driver) self.terms_conditions_page=TermsConditionsPage(driver) + self.target_help_page=TargetHelpPage(driver) + + + -app=Application(driver) diff --git a/CSS_selectors amazon.py b/CSS_selectors amazon.py deleted file mode 100644 index 0b552e33..00000000 --- a/CSS_selectors amazon.py +++ /dev/null @@ -1,27 +0,0 @@ -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 - -# 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() - -driver.get('https://www.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0') -sleep(5) -driver.find_element(By.CSS_SELECTOR,'i.a-icon.a-icon-logo') -driver.find_element(By.CSS_SELECTOR,'h1.a-spacing-small') -driver.find_element(By.CSS_SELECTOR,'#ap_customer_name') -driver.find_element(By.CSS_SELECTOR,'#ap_email') -driver.find_element(By.CSS_SELECTOR,'#ap_password') -driver.find_element(By.CSS_SELECTOR,'div.a-alert-content') -driver.find_element(By.CSS_SELECTOR,'#ap_password_check') -driver.find_element(By.CSS_SELECTOR,'#continue') -driver.find_element(By.CSS_SELECTOR,"[href*='/gp/help/customer/display.html/ref=ap_register_notification_condition_of_use']") -driver.find_element(By.CSS_SELECTOR,"[href*='/gp/help/customer/display.html/ref=ap_register_notification_privacy_notice?i']") -driver.find_element(By.CSS_SELECTOR,"a.a-link-emphasis") diff --git a/PP.txt b/PP.txt deleted file mode 100644 index 81e60d93..00000000 --- a/PP.txt +++ /dev/null @@ -1,7 +0,0 @@ -Year_born = str(input('Enter year born: ')) -Name = input('Enter your name: ') - -message = f'Hello, {Name}. You were born in the year {Year_born}.' -print(message) - - diff --git a/Pages/base_page.py b/Pages/base_page.py index 486fd5ac..d22f04d5 100644 --- a/Pages/base_page.py +++ b/Pages/base_page.py @@ -1,10 +1,10 @@ +from selenium.webdriver.support.select import Select from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class BasePage: - def __init__(self, driver): self.driver = driver self.wait = WebDriverWait(driver, 15) @@ -13,7 +13,7 @@ def open_url(self,url): self.driver.get(url) def get_url(self): - return self.driver.current_url + return self.driver.current_url() def click(self,*locator): self.driver.find_element(*locator).click() @@ -25,7 +25,7 @@ def input_text(self,text,*locator): self.driver.find_element(*locator).send_keys(text) def get_current_window_handle(self): - return self.driver.current_window_handle + return self.driver.current_window_handle() def switch_to_new_window(self): self.wait.until(EC.new_window_is_opened()) @@ -38,12 +38,15 @@ def switch_to_original_window(self,window_id): self.driver.switch_to.window(window_id) print("Current Window: ", self.driver.current_window_handle) + def select_topic(self, option_value): + dd = self.find_element(*self.option_value) + select = Select(dd) + select.select_by_value(option_value) + def wait_for_element_visible(self, locator): - return self.wait.until( - EC.visibility_of_element_located(locator), - message=f'Element by {locator} not visible' - ) + return self.wait.until(EC.visibility_of_element_located(locator), + message=f'Element by {locator} not visible') def wait_for_element_invisible(self, locator): self.wait.until( @@ -57,7 +60,7 @@ def wait_for_element_clickable(self, locator): message=f'Element by {locator} not clickable' ) - def wait_and_click(self, *locator): + def wait_and_click(self,locator): self.wait.until( EC.element_to_be_clickable(locator), message=f'Element by {locator} not clickable' diff --git a/Pages/help_page.py b/Pages/help_page.py new file mode 100644 index 00000000..84c8e7d9 --- /dev/null +++ b/Pages/help_page.py @@ -0,0 +1,36 @@ +from selenium.webdriver.common.by import By +from Pages.base_page import BasePage + + +# #class HelpPage(BasePage): +# TOPIC_SELECTION_DD = (By.CSS_SELECTOR, "select[id*='ViewHelpTopics']") +# HEADER = (By.XPATH, "//h1[text()=' {SUBSTRING}']") +# +# def _get_header_locator(self, header): +# # HEADER (By.XPATH, "//h1[text()=' {SUBSTRING}']") => (By.XPATH, "//h1[text()=' Returns']") +# return [self.HEADER[0], self.HEADER[1].replace('{SUBSTRING}', header)] +# +# +# def open_help_page(self): +# self.open_url("https://help.target.com/help/SubCategoryArticle?childcat=Returns&parentcat=Returns+%26+Exchanges") +# +# +# def choose_topic(self): +# self.select_topic(*self.TOPIC_SELECTION_DD) +# +# +# def verify_target_help_page_opened(self): +# self.verify_url("https://help.target.com/help/SubCategoryArticle?childcat=Returns&parentcat=Returns+%26+Exchanges") +# +# +# def verify_topic_page_opened(self,header): +# locator = self._get_header_locator(header) +# print(locator) +# self.wait_for_element_visible(locator) + + + + + + + diff --git a/Pages/sign_in.py b/Pages/sign_in.py index a8c11bc7..d01d5ffa 100644 --- a/Pages/sign_in.py +++ b/Pages/sign_in.py @@ -5,18 +5,37 @@ class SignPage(BasePage): Terms_conditions = (By.XPATH,"//a[contains(text(),'Terms')]") + EMAIL = (By.CSS_SELECTOR, "#username") + CONTINUE = (By.CSS_SELECTOR, "#login" ) + PASSWORD = (By.CSS_SELECTOR, "#password") + SIGN_IN = (By.CSS_SELECTOR, "#login") + ERROR = (By.CSS_SELECTOR, "#password--ErrorMessage") + def open_sign_in(self): self.open_url('https://www.target.com/login?client_id=ecom-web-1.0.0&ui_namespace=ui-default&back_button_action=browser&keep_me_signed_in=true&kmsi_default=false&actions=create_session_request_username') + def enter_email(self): + self.input_text("katie@gmail.com ",*self.EMAIL) + + def click_continue(self): + self.click(*self.CONTINUE) + + def enter_password(self): + self.input_text("password",*self.PASSWORD) + + def click_sign_in(self): + self.click(*self.SIGN_IN) def click_terms(self): self.click(self.Terms_conditions) - def verify_terms_opened(self): self.verify_partial_url('terms-conditions') + def verify_error_message(self): + self.verify_text("Please enter a valid password",*self.ERROR) + diff --git a/Pages/target_help_page.py b/Pages/target_help_page.py new file mode 100644 index 00000000..bd9c9571 --- /dev/null +++ b/Pages/target_help_page.py @@ -0,0 +1,29 @@ +from Pages.base_page import BasePage +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import Select +from time import sleep + +class TargetHelpPage(BasePage): + DD = (By.CSS_SELECTOR, "[name='j_id0:contentTemplate:j_id79:j_id80:viewHelpTopics:ViewHelpTopics']") + + def open_target_help_page(self): + self.open_url("https://help.target.com/help/SubCategoryArticle?childcat=Returns&parentcat=Returns+%26+Exchanges") + sleep(5) + + def verify_help_page_opened(self): + self.verify_url("https://help.target.com/help/SubCategoryArticle?childcat=Returns&parentcat=Returns+%26+Exchanges") + + def select_topic_target_help_page(self): + dropdown = self.find_element(*self.DD) + select = Select(dropdown) + select.select_by_value('Orders & Purchases') + sleep(5) + + def verify_orders_and_purchases_opened(self): + self.verify_url("https://help.target.com/help/SubCategoryArticle?childcat=Print+a+receipt&parentcat=Orders+%26+Purchases&searchQuery=") + + + + + + diff --git a/features/environment.py b/features/environment.py index acf322d4..bf41b2b1 100755 --- a/features/environment.py +++ b/features/environment.py @@ -2,48 +2,46 @@ from selenium.webdriver.chrome.service import Service from selenium.webdriver.support.wait import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager -from app.application import Application +from Application.application import Application from webdriver_manager.firefox import GeckoDriverManager from selenium.webdriver.chrome.options import Options +def browser_init(context, scenario_name): + """ + :param scenario_name: + :param context: Behave context + """ + driver_path = ChromeDriverManager().install() + service = Service(driver_path) + context.driver = webdriver.Chrome(service=service) -def browser_init(context): - def browser_init(context, scenario_name): - """ - :param context: Behave context - """ - driver_path = ChromeDriverManager().install() - service = Service(driver_path) - context.driver = webdriver.Chrome(service=service) + # ### BROWSERSTACK ### + # # Register for BrowserStack, then grab it from https://www.browserstack.com/accounts/settings + # bs_user = 'poojap_n58Du0' + # bs_key = 'jFHNdxSxEVo9CJ5NkVsV' + # url = f'http://{bs_user}:{bs_key}@hub-cloud.browserstack.com/wd/hub' + # + # options = Options() + # bstack_options = { + # "os": "Windows", + # "osVersion": "11", + # 'browserName': 'edge', + # 'sessionName': scenario_name, + # } + # options.set_capability('bstack:options', bstack_options) + # context.driver = webdriver.Remote(command_executor=url, options=options) + + context.driver.maximize_window() context.driver.wait = WebDriverWait(context.driver, 15) context.app = Application(context.driver) + #context.driver.implicitly_wait(5) - - ### BROWSERSTACK ### - # Register for BrowserStack, then grab it from https://www.browserstack.com/accounts/settings - bs_user = 'poojap_n58Du0' - bs_key = 'jFHNdxSxEVo9CJ5NkVsV' - url = f'http://{bs_user}:{bs_key}@hub-cloud.browserstack.com/wd/hub' - - options = Options() - bstack_options = { - "os": "Windows", - "osVersion": "11", - 'browserName': 'edge', - 'sessionName': scenario_name, - } - options.set_capability('bstack:options', bstack_options) - context.driver = webdriver.Remote(command_executor=url, options=options) - - context.driver.maximize_window() - context.driver.implicitly_wait(5) def before_scenario(context, scenario): print('\nStarted scenario: ', scenario.name) - browser_init(context) browser_init(context, scenario.name) def before_step(context, step): diff --git a/features/steps/cart_empty.py b/features/steps/cart_empty.py index 585e798e..3c283eb4 100644 --- a/features/steps/cart_empty.py +++ b/features/steps/cart_empty.py @@ -7,6 +7,7 @@ def click_cart_icon(context): context.app.cart_empty.click_cart.click() + @then("Verify “Your cart is empty” message is shown") def verify_cart_empty(context): expected_text = "Your cart is empty" diff --git a/features/steps/product colors steps.py b/features/steps/product colors steps.py index 03166a6a..b2ab5e09 100644 --- a/features/steps/product colors steps.py +++ b/features/steps/product colors steps.py @@ -12,22 +12,22 @@ def product_page(context): @then("Verify if product with specific color is displayed") def verify_product_color(context): - product_color = ["Blue Tint", "Denim Blue", "Raven", "Marine"] - actual_colors = [] + product_color = ["Blue Tint", "Denim Blue", "Raven", "Marine"] + actual_colors = [] - colors = context.driver.find_elements(By.CSS_SELECTOR,"div[aria-label='Carousel']") + colors = context.driver.find_elements(By.CSS_SELECTOR,"div[aria-label='Carousel']") -for color in colors: - color.click() + for color in colors: + color.click() - selected_colors= context.driver.find_element(By.CSS_SELECTOR,"[data-test='@web/VariationComponent'] div") - print('Current color',selected_colors) + selected_colors= context.driver.find_element(By.CSS_SELECTOR,"[data-test='@web/VariationComponent'] div") + print('Current color',selected_colors) - selected_color = selected_color.split('\n')[1] # remove 'Color\n' part, keep Black' - actual_colors.append(selected_color) - print(actual_colors) + selected_color = selected_color.split('\n')[1] # remove 'Color\n' part, keep Black' + actual_colors.append(selected_color) + print(actual_colors) -assert expected_colors == actual_colors, f'Expected {expected_colors} did not match actual {actual_colors}' + assert selected_color == actual_colors, f'Expected {selected_color} did not match actual {actual_colors}' diff --git a/features/steps/sign in steps.py b/features/steps/sign in steps.py index 327b9871..72548f6b 100644 --- a/features/steps/sign in steps.py +++ b/features/steps/sign in steps.py @@ -6,31 +6,63 @@ def open_sign_in_page(context): context.app.sign_in.open_sign_in() + @when('Store original window') def store_original_window(context): context.original_window= context.app.sign_in.get_current_window_handle() + @when('Click on Target terms and conditions link') def click_target_terms_and_conditions(context): context.app.sign_in.click_terms() + @when('Switch to the newly opened window') def switch_to_newly_opened_window(context): context.app.sign_in.switch_to.window(context.driver.window_handle[1]) + +@when("user inputs correct email address") +def enter_email(context): + context.app.sign_in.enter_email() + + +@when("User clicks continue button") +def continue_button(context): + context.app.sign_in.click_continue() + + +@when("user enters incorrect password") +def enter_password(context): + context.app.sign_in.enter_password() + + +@when("Clicks sign in with password") +def clicks_sign_in_password(context): + context.app.sign_in.click_sign_in() + + + @then('Verify Terms and Conditions page is opened') def verify_terms_and_conditions_page(context): context.app.terms_conditions_page.verify_terms() + @then('User can close new window') def user_close_new_window(context): context.app.terms_conditions_page.close() + @then('switch back to original') def switch_to_original_window(context): context.app.sign_in.switch_to_original_window(context.original_window) +@then("Verify error message is shown") +def verify_error_message(context): + context.app.sign_in.verify_error_message() + + diff --git a/features/steps/target_help_steps.py b/features/steps/target_help_steps.py new file mode 100644 index 00000000..96cb95c9 --- /dev/null +++ b/features/steps/target_help_steps.py @@ -0,0 +1,24 @@ +from behave import given, when, then + + + +@given("Open Target Help Page") +def open_help_page(context): + context.app.target_help_page.open_target_help_page() + + +@then("Verify Target Help Page Opened") +def verify_target_help_page_opened(context): + context.app.target_help_page.verify_help_page_opened() + + +@then("Select Target topic Orders and Purchases") +def select_target_topic_orders_and_purchases(context): + context.app.target_help_page.select_topic_target_help_page() + + +@then("Verify Orders and Purchases page opened") +def verify_orders_and_purchases(context): + context.app.target_help_pageverify_orders_and_purchases_opened() + + diff --git a/features/tests/sign in .feature b/features/tests/sign in .feature index 67e2cfcb..809a906d 100644 --- a/features/tests/sign in .feature +++ b/features/tests/sign in .feature @@ -1,8 +1,20 @@ -Feature: Logged out user can sign in +Feature: Sign In Scenario: User can sign into target account Given Target main page When user clicks on sign in button When user clicks on side navigation side in button Then Verify if Sign in message is displayed + +Scenario: User cannot sign in with incorrect password + Given Open Target page + When user clicks on sign in button + And user clicks on side navigation side in button + And user inputs correct email address + And User clicks continue button + When user enters incorrect password + And Clicks sign in with password + Then Verify error message is shown + + diff --git a/features/tests/target_help.feature b/features/tests/target_help.feature new file mode 100644 index 00000000..815a5361 --- /dev/null +++ b/features/tests/target_help.feature @@ -0,0 +1,10 @@ + +Feature: Dropdown menu on Target Help page + + Scenario: User can select different topics on Target Help Page + Given Open Target Help Page + Then Verify Target Help Page Opened + Then Select Target topic Orders and Purchases + Then Verify Orders and Purchases page opened + + diff --git a/features/tests/window handling test case .feature b/features/tests/window handling test case .feature deleted file mode 100644 index 460da3a8..00000000 --- a/features/tests/window handling test case .feature +++ /dev/null @@ -1,9 +0,0 @@ -Feature: Window Handling test case - - Scenario: User can open and close Terms and Conditions from sign in page - Given Open sign in page - When Store original window - And Click on Target terms and conditions link - And Switch to the newly opened window - Then Verify Terms and Conditions page is opened - And User can close new window and switch back to original \ No newline at end of file diff --git a/homework 2 b/homework 2 deleted file mode 100644 index 00d6489b..00000000 --- a/homework 2 +++ /dev/null @@ -1,18 +0,0 @@ -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 - -# 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.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&') - -driver.find_element(By.XPATH, "" \ No newline at end of file diff --git a/homework 2.py b/homework 2.py deleted file mode 100644 index 97891f94..00000000 --- a/homework 2.py +++ /dev/null @@ -1,39 +0,0 @@ -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 - -# 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') - -sleep(2) -#verify if sign in button works -driver.find_element(By.XPATH,"//a[@data-test='@web/AccountLink']").click() -sleep(2) - -#verify if side navigation "sign in" button works -driver.find_element(By.XPATH,"//a[@data-test='accountNav-signIn']").click() -sleep(2) - -#SignIn button is shown -driver.find_element(By.ID,"login").click() - - - - - - - - - - - diff --git a/homework lesson 2.py b/homework lesson 2.py deleted file mode 100644 index febc2fff..00000000 --- a/homework lesson 2.py +++ /dev/null @@ -1,27 +0,0 @@ -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 - -# 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.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&') - -driver.find_element(By.XPATH, "//i[@class='a-icon a-icon-logo']") -driver.find_element(By.ID,'ap_email') -driver.find_element(By.ID,'continue') -driver.find_element(By.ID, "auth-fpp-link-bottom") -driver.find_element(By.ID, "ap-other-signin-issues-link") -driver.find_element(By.ID,"createAccountSubmit") -driver.find_element(By.XPATH,"//span[@class='a-expander-prompt']") -driver.find_element(By.XPATH,'//a[@href="/gp/help/customer/display.html/ref=ap_signin_notification_privacy_notice?ie=UTF8&nodeId=468496"]') -driver.find_element(By.XPATH,'//a[@href="/gp/help/customer/display.html/ref=ap_signin_notification_condition_of_use?ie=UTF8&nodeId=508088"]') - diff --git a/locators.py b/locators.py deleted file mode 100644 index 2d2a66e5..00000000 --- a/locators.py +++ /dev/null @@ -1,15 +0,0 @@ -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 - -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.google.com/') diff --git a/python practice.py b/python practice.py deleted file mode 100644 index 139597f9..00000000 --- a/python practice.py +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/requirements.txt b/requirements.txt deleted file mode 100755 index 28461e89..00000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -allure-behave -behave -selenium -webdriver-manager \ No newline at end of file diff --git a/target homework lesson 2.py b/target homework lesson 2.py deleted file mode 100644 index b6bc2374..00000000 --- a/target homework lesson 2.py +++ /dev/null @@ -1,27 +0,0 @@ -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 - -# 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() - -driver.get('www.target.com') -sleep(5) -driver.find_element(By.XPATH,"//span[text()='Sign in']").click() -driver.find_element(By.XPATH,"//button[@data-test='accountNav-signIn']").click() -sleep(10) -#Verification -expected_result ='Sign into your Target account' -actual_result =driver.find_element(By.XPATH,"//h1[@class='sc-fe064f5c-0 sc-315b8ab9-2 lnvRvp diHlfH']") -assert expected_result in actual_result,f'Expected text {expected_result} not in actual {actual_result}' -print("Test Case passed") - -driver.find_element(By.ID,'login') - diff --git a/walmart practice coding.py b/walmart practice coding.py deleted file mode 100644 index 6f184c98..00000000 --- a/walmart practice coding.py +++ /dev/null @@ -1,4 +0,0 @@ -user_name = input("What's your name: ") - -def greet(user_name): - print("Hello," + user_name)