Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Amazon Sign In Test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from sample_script import driver
# Amazon logo
driver.find_element(By.XPATH, "//*[@aria-label='Amazon']")

#Email field
driver.find_element(By.XPATH, "//input[@class='a-input-text']")

# Continue button, By ID
driver.find_element(By.ID, 'continue-announce')

# Conditions of use link
driver.find_element(By.XPATH, "//a[text()= 'Conditions of Use']")

# Privacy Notice link
driver.find_element(By.XPATH, "//a[text()= 'Privacy Notice']")

# Need help link
driver.find_element(By.XPATH, "//a[@class='a-size-base a-link-normal']")

# Create a free business account
driver.find_element(By.XPATH, "//a[@class='a-link-normal']")
27 changes: 27 additions & 0 deletions Amazon Sign In Test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from sample_script import driver
from selenium.webdriver.common.by import By

# Amazon logo
driver.find_element(By.XPATH, "//*[@aria-label='Amazon']")

#Email field
driver.find_element(By.XPATH, "//input[@class='a-input-text']")

# Continue button, By ID
driver.find_element(By.ID, 'continue-announce')

# Conditions of use link
driver.find_element(By.XPATH, "//a[text()= 'Conditions of Use']")

# Privacy Notice link
driver.find_element(By.XPATH, "//a[text()= 'Privacy Notice']")

# Need help link
driver.find_element(By.XPATH, "//a[@class='a-size-base a-link-normal']")

# Create a free business account
driver.find_element(By.XPATH, "//a[@class='a-link-normal']")




23 changes: 23 additions & 0 deletions Stack Overflow Test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Create your account
driver.find_element(By.XPATH, "//h1[@class='flex--item fs-headline1 fw-bold lh-xs mb8 ws-nowrap']")

# 'Terms of service' paragraph
driver.find_element(By.XPATH, "//div[@class='flex--item js-terms fs-caption fc-black-400 ta-left']")

# Email
driver.find_element(By.ID, "email")

# Password
driver.find_element(By.ID, "password")

# Sign- Up Button
driver.find_element(By.ID, "submit-button")

# Sign-up w/ button
diver.find_element(By.XPATH, "//button[@data-provider='google']")

# Sign -up w/ GitHub
driver.find_element(By.XPATH, "//button[@data-provider='github']")

# Get Stack Overflow for Teams
driver.find_element(By.XPATH, "//a[text()='Get Stack Overflow Internal free for up to 50 users']")
19 changes: 19 additions & 0 deletions Target Test w/Target Sign-In.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from selenium import webdriver
from time import sleep

from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.maximize_window()

# open the url
driver.get('https://www.target.com/')

# sign In
driver.find_element(By.XPATH, "//span[text()='Account']").click()
driver.find_element(By.XPATH, "//button[@data-test='accountNav-signIn']").click()

# verify
expected = 'Sign in or create account'
actual = driver.find_element(By.XPATH, "//h1[text()='Sign in or create account']").text
assert expected == actual, f'Expected {expected} did not match actual {actual}'
31 changes: 31 additions & 0 deletions Target Test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from selenium import webdriver
from time import sleep

from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(5)

# open the url
driver.get('https://www.target.com/')

# Click Account Button
driver.find_element(By.XPATH, "//a[@data-test='@web/AccountLink']").click()
driver.find_element(By.XPATH, "//*[text()='Account']").click()
driver.find_element(By.XPATH, "//button[@data-test='accountNav-signIn']").click()

# Verify Sign-in page open
expected_text = 'Sign in or create account'
actual_text = driver.find_element(By.XPATH,"//*[text()='Sign in or create account']")
assert expected_text == actual_text, f'Expect text{expected_text} did not match actual text {actual_text}'

# Make sure login button is shown
driver.find_element(By.ID, 'login')


driver.quit()



#
14 changes: 14 additions & 0 deletions app/application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pages.base_page import Page
from pages.cart_page import Cart_Page
from pages.header import Header
from pages.main_page import MainPage
from pages.search_results_page import SearchResultsPage


class Application:
def __init__(self, driver):
self.cart_page = Cart_Page(driver)
self.header = Header(driver)
self.main_page = MainPage(driver)
self.page = Page(driver)
self.search_results_page = SearchResultsPage(driver)
8 changes: 7 additions & 1 deletion features/environment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
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 selenium.webdriver.support import expected_conditions as EC


from app.application import Application


def browser_init(context):
Expand All @@ -13,7 +18,8 @@ def browser_init(context):

context.driver.maximize_window()
context.driver.implicitly_wait(4)

context.driver.wait = WebDriverWait(context.driver, timeout=10)
context.app = Application(context.driver)

def before_scenario(context, scenario):
print('\nStarted scenario: ', scenario.name)
Expand Down
22 changes: 22 additions & 0 deletions features/steps/add_to_target_cart_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from time import sleep

from selenium.webdriver.common.by import By
from behave import given, when, then
from selenium.webdriver.support.wait import WebDriverWait
from selenium. webdriver.support import expected_conditions as EC

@when('Click on add to cart button')
def click_add_to_cart(context):
sleep(20)
context.driver.find_element(By.CSS_SELECTOR, "[data-test='chooseOptionsButton']").click()
sleep(5)
context.driver.wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '[aria-label="Fulfillment"] [id*="addToCartButtonOrTextIdFor"]'))).click()


@then('Confirm added to cart message from side navigation')
def added_to_cart_message_from_side_navigation(context):
sleep(5)
actual_text = context.driver.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'h2[data-test="modal-drawer-heading"] span[class="h-text-lg"]'))).text

expected_text = 'Added to cart'
assert actual_text==expected_text, f'Expected text to be {expected_text}, but got {actual_text}'
28 changes: 28 additions & 0 deletions features/steps/header_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from selenium.webdriver.common.by import By
from behave import given, when, then





@when('Search for {product}')
def search_for_product(context, product):
context.app.header.search(product)
#context.driver.find_element(By.ID, 'search').send_keys(product)
#context.driver.find_element(By.CSS_SELECTOR, '[data-test="@web/Search/SearchButton"]').click()


@when('Click on account button')
def click_on_account_button(context):
context.driver.find_element(By.CSS_SELECTOR, '[aria-label="Account, sign in"]').click()


@when('Open target circle')
def open_target_circle(context):
context.driver.find_element(By.ID, 'utilityNav-circle').click()


@when('Click on Cart Icon')
def click_on_cart_icon(context):
#context.driver.find_element(By.XPATH, '//a[@data-test="@web/CartLink"]').click()
context.app.header.click_on_cart_icon()
8 changes: 8 additions & 0 deletions features/steps/main_page_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from selenium.webdriver.common.by import By
from behave import given, when, then


@given("Open target main page")
def open_target_main_page(context):
context.driver.get('https://www.target.com/')

17 changes: 17 additions & 0 deletions features/steps/seach_results_page_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from selenium.webdriver.common.by import By
from behave import given, when, then





@then('Search results for cart button')
def search_results_for_cart(context):
context.app.search_results_page.verify_search_results()







29 changes: 29 additions & 0 deletions features/steps/target_cart_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from selenium.webdriver.common.by import By
from behave import given, when, then


@when('Click on Cart Icon')
def click_on_cart_icon(context):
context.driver.find_element(By.XPATH, '//a[@data-test="@web/CartLink"]').click()


@then('"Your cart is empty" message is shown')
def verify_empty_cart_message(context):
actual_text = context.driver.find_element(By.XPATH, "//h1[contains(@class, styles_ndsHeading)]").text
assert 'Your cart is empty' in actual_text, f"Expected 'Your cart is empty' text not in {actual_text}"


@when('Click on Sign In or Create Account button')
def sign_in_or_create_account_button(context):
context.driver.find_element(By.XPATH, "//button[@data-test='accountNav-signIn']").click()


@then('"Sign in or create account" page is shown')
def verify_sign_in_message(context):
actual_text = context.driver.find_element(By.XPATH,"//*[text()='Sign in or create account']")
assert "Sign in or create account" in actual_text, f"Expected 'Sign in or create account' text not in {actual_text}"





36 changes: 36 additions & 0 deletions features/steps/target_circle_page_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from selenium.webdriver.common.by import By
from behave import given, when, then


# find benefits cells
@when('Click for benefit cells')
def verify_benefits_cells(context):
context.driver.find_element(By.XPATH, "//button[@data-test='storycard--staticButton']").click()


@then('Sign in or create account page')
def sign_in_or_create_account_page(context):
actual_text = context.driver.find_element(By.XPATH, "//h1[contains(text(),'Sign in or create account')]").text
assert 'Sign in or create account' in actual_text, f"Expected 'Sign in or create account' text not in {actual_text}"


@when('Click for pharmacy')
def click_pharmacy(context):
context.driver.find_element(By.CSS_SELECTOR, '[aria-label="Pharmacy"]').click()


@then('CVS Pharmacy & Vaccines page')
def CVS_Pharmacy_Vaccines_page(context):
actual_text = context.driver.find_element(By.XPATH, "//h1[contains(text(), 'CVS Pharmacy & Vaccines')]").text
assert 'CVS Pharmacy & Vaccines' in actual_text, f"Expected 'CVS Pharmacy & Vaccines' text not in {actual_text}"


@when('Click for target help')
def verify_help(context):
context.driver.find_element(By.CSS_SELECTOR, '[aria-label="Target Help"]').click()


@then('Verify the help page opens')
def verify_help_page_opens(context):
actual_text = context.driver.find_element(By.CSS_SELECTOR, "[aria-current='page']").text
assert 'Help' in actual_text, f"Expected 'Help' text not in {actual_text}"
38 changes: 38 additions & 0 deletions features/steps/target_product_colors_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from behave import then, given
from selenium.webdriver.common.by import By
from time import sleep



@given('Open target product A-94089062 page')
def open_target(context):
context.driver.get('https://www.target.com/p/josmo-boys-slip-on-casual-boat-style-shoes-little-kids-toddler-tan-size-10/-/A-94089062')
sleep(5)


@then('Verify that every product color is clicked and correct')
def verify_product_color_is_clicked_correct(context):
expected_colors = ['black', 'tan']
actual_colors = []


COLOR_CHOICES = (By.CSS_SELECTOR, 'a[class*="styles_ndsBaseButton"] img[class*="styles_pictureLazy"]')
SELECTED_COLOR = (By.CSS_SELECTOR, '[data-test="@web/VariationComponent"] div[class*="styles_headerWrapper"]')

colors = context.driver.find_elements(*COLOR_CHOICES)
print(colors)


for color in colors:
color.click()
sleep(10)

selected_color = context.driver.find_elements(*SELECTED_COLOR)[1].text

selected_color = selected_color.split('\n')[1]
actual_colors.append(selected_color)

assert expected_colors == actual_colors, f"Expected colors are: ({expected_colors}), but got Actual colors: ({actual_colors}) "



8 changes: 8 additions & 0 deletions features/steps/update_target_product_search_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from selenium.webdriver.common.by import By
from behave import given, when, then


@then('Search results for product are shown')
def verify_product_results_shown(context):
actual_text = context.driver.find_element(By.CSS_SELECTOR, 'div[data-module-type="ListingPageResultsCount"] h2').text
assert 'results' in actual_text, f"Expected 'results' text not in {actual_text}"
11 changes: 11 additions & 0 deletions features/tests/add_to_target_cart.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# created by rollyn

Feature: User can add any product to cart

Scenario: User can add product to cart
Given Open target main page
When Search for tea
And Click on add to cart button
Then Confirm added to cart message from side navigation


7 changes: 7 additions & 0 deletions features/tests/cart_page.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# created by rollyn
Feature: Rewrite this scenario with Page Object pattern:

Scenario: "Your cart is empty" message is shown for empty cart
Given Open target main page
When Click on Cart Icon
Then "Your cart is empty" message is shown
14 changes: 14 additions & 0 deletions features/tests/target_cart_feature.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# created by rollyn
Feature: Test Scenarios for Target's Cart and Sign In Button functionality

Scenario: User can use Target cart buttons
Given Open target main page
When Click on Cart Icon
Then "Your cart is empty" message is shown


Scenario: User can navigate to "sign In"
Given Open target main page
When Click on account button
And Click on Sign In or Create Account button
Then "Sign in or create account" page is shown
Loading