-
Notifications
You must be signed in to change notification settings - Fork 394
Feature #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tuychim
wants to merge
12
commits into
careerist-qa:main
Choose a base branch
from
tuychim:feature
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature #35
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
661c202
update automated search script
tuychim e93ca5f
Update files
tuychim d35850b
First commit
tuychim 01c40f4
Add new test cases file
tuychim f661c12
Add test cases
tuychim 7871533
add commit
tuychim 097ed8e
updating file
tuychim 2d01f6a
updated Target product search
tuychim d3193a8
lesson 4
tuychim 36b37c7
Updated files
tuychim b201dde
Updated code for Page Objects
tuychim 58a6b0a
updated test scenerio
tuychim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from pages.base_page import Page | ||
from pages.cart_page import CartPage | ||
from pages.header import Header | ||
from pages.main_page import MainPage | ||
from pages.search_result_page import SearchResultsPage | ||
from pages.cart_page import CartPage | ||
from pages.sign_in_page import SignIn | ||
|
||
|
||
class Application: | ||
|
||
def __init__(self, driver): | ||
self.base_page = Page(driver) | ||
self.cart_page = CartPage(driver) | ||
self.header = Header(driver) | ||
self.main_page = MainPage(driver) | ||
self.search_result_page = SearchResultsPage(driver) | ||
self.sign_in_page = SignIn(driver) | ||
self.pages = Page(driver) | ||
|
||
|
||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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('http://www.target.com/') | ||
|
||
driver.find_element(By.XPATH, "//span[@class='styles__LinkText-sc-1e1g60c-3 dZfgoT h-margin-r-x3']").click() | ||
|
||
driver.find_element(By.XPATH, "//*[@id='listaccountNav-signIn']/a/span").click() | ||
sleep(6) | ||
actual_text = driver.find_element(By.XPATH, "//*[@id='__next']/div/div/div/div[1]/div/h1/span").text | ||
#Sign in button | ||
driver.find_element(By.XPATH, "//button[@type='submit']") | ||
|
||
driver.quit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from selenium.webdriver.common.by import By | ||
from behave import when, then | ||
|
||
CART_SUMMARY = (By.CSS_SELECTOR, "[class*='CartSummarySpan']") | ||
CART_ITEM_TITLE = (By.CSS_SELECTOR, "[data-test='cartItem-title']") | ||
|
||
|
||
@when('Open cart page') | ||
def open_cart(context): | ||
context.driver.get('https://www.target.com/cart') | ||
|
||
|
||
@then('Verify cart has correct product') | ||
def verify_product_name(context): | ||
actual_name = context.driver.find_element(*CART_ITEM_TITLE).text | ||
assert context.product_name in actual_name, f"Expected {context.product_name} but got {actual_name}" | ||
|
||
|
||
@then('Verify cart has {amount} item(s)') | ||
def verify_cart_items(context, amount): | ||
cart_summary = context.driver.find_element(*CART_SUMMARY).text | ||
assert amount in cart_summary, f"Expected {amount} items but got {cart_summary}" | ||
|
||
|
||
@then("Verify 'Your cart is empty' message is shown") | ||
def verify_cart_empty_message(context): | ||
context.app.cart_page.verify_cart_empty_message() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from selenium.webdriver.common.by import By | ||
from behave import given, when, then | ||
from time import sleep | ||
from pages import sign_in_page | ||
|
||
|
||
@given('Open Target main page') | ||
def open_target(context): | ||
context.app.main_page.open_main() | ||
|
||
|
||
@when("Click Sign in") | ||
def click_sign_in(context): | ||
context.app.sign_in_page.click_sign_in() | ||
|
||
|
||
@then('From side nav menu, click Sign in') | ||
def side_nav_sign_in_btn(context): | ||
context.app.sign_in_page.side_nav_sign_in_btn() | ||
|
||
|
||
@then('Verify Sign in form opened') | ||
def verify_sign_in_shown(context): | ||
context.app.base_page.verify_sign_in_shown('Sign into your Target account') | ||
sleep(8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from selenium.webdriver.common.by import By | ||
from behave import given, then | ||
from time import sleep | ||
|
||
|
||
COLOR_OPTIONS = (By.CSS_SELECTOR, "[class*='ButtonWrapper'] img") | ||
SELECTED_COLOR = (By.CSS_SELECTOR, "[class*='StyledVariationSelectorImage'] [class*='StyledHeaderWrapperDiv']") | ||
|
||
|
||
@given('Open target product {product_id} page') | ||
def open_target(context, product_id): | ||
context.driver.get(f'https://www.target.com/p/{product_id}') | ||
sleep(8) | ||
|
||
|
||
@then('Verify user can click through colors') | ||
def click_and_verify_colors(context): | ||
expected_colors = ['Blue Tint', 'Denim Blue', 'Marine', 'Raven'] | ||
actual_colors = [] | ||
|
||
colors = context.driver.find_elements(*COLOR_OPTIONS) # [webelement1, webelement2, webelement3] | ||
for color in colors: | ||
color.click() | ||
|
||
selected_color = context.driver.find_element(*SELECTED_COLOR).text # 'Color\nBlack' | ||
print('Current color', selected_color) | ||
|
||
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}' | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support import expected_conditions as EC | ||
|
||
from behave import then | ||
from time import sleep | ||
|
||
|
||
|
||
SEARCH_RESULT_HEADER = (By.XPATH, "//div[@data-test='resultsHeading']") | ||
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, "[class*='ProductCardImage']") | ||
|
||
|
||
@then('Verify search results are shown for {expected_item}') | ||
def verify_search_results(context, expected_item): | ||
context.app.search_result_page.verify_search_results(expected_item) | ||
|
||
|
||
@then('Verify that URL has {partial_url}') | ||
def verify_search_page_url(context, partial_url): | ||
context.app.search_result_page.verify_partial_url(partial_url) | ||
|
||
|
||
@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)", "") | ||
|
||
all_products = context.driver.find_elements(*LISTINGS) # [WebEl1, WebEl2, WebEl3, WebEl4] | ||
|
||
for product in all_products: | ||
title = product.find_element(*PRODUCT_TITLE).text | ||
assert title, 'Product title not shown' | ||
product.find_element(*PRODUCT_IMG) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('http://www.target.com/') | ||
|
||
driver.find_element(By.XPATH, "//span[@class='styles__LinkText-sc-1e1g60c-3 dZfgoT h-margin-r-x3']").click() | ||
|
||
driver.find_element(By.XPATH, "//*[@id='listaccountNav-signIn']/a/span").click() | ||
sleep(6) | ||
actual_text = driver.find_element(By.XPATH, "//*[@id='__next']/div/div/div/div[1]/div/h1/span").text | ||
#Sign in button | ||
driver.find_element(By.XPATH, "//button[@type='submit']") | ||
driver.quit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Feature: Cart tests | ||
|
||
Scenario: 'Your cart is empty' message is shown for empty cart | ||
Given Open target main page | ||
When Click on Cart icon | ||
Then Verify 'Your cart is empty' message is shown | ||
|
||
Scenario: User can add a product to cart | ||
Given Open target main page | ||
When Search for Ice Tea | ||
And Click on Add to Cart button | ||
And Store product name | ||
And Confirm Add to Cart button from side navigation | ||
And Open cart page | ||
Then Verify cart has 1 item(s) | ||
And Verify cart has correct product |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Feature: Tests for main page UI | ||
|
||
Scenario: Verify header in shown | ||
Given Open Target main page | ||
Then Verify header in shown | ||
|
||
Scenario: Verify header has correct amount links | ||
Given Open Target main page | ||
Then Verify header has 5 links |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Feature: Tests for product page | ||
|
||
Scenario: User can select colors | ||
Given Open target product A-54551690 page | ||
Then Verify user can click through colors |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Feature: Target Sign In | ||
|
||
Scenario: Logged out user can Sign in | ||
Given Open Target main page | ||
When Click Sign in | ||
Then From side nav menu, click Sign in | ||
And Verify Sign in form opened |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Feature: Search tests | ||
|
||
|
||
Scenario: User can search for a tea | ||
Given Open Target main page | ||
When Search for icetea | ||
Then Verify search results are shown for icetea | ||
Then Verify that URL has icetea | ||
|
||
Scenario Outline: User can search for a product | ||
Given Open Target main page | ||
When Search for <item> | ||
Then Verify search results are shown for <expected_item> | ||
Examples: | ||
|item |expected_item | | ||
|mug |mug | | ||
|tea |tea | | ||
|white mug |white mug | |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍