-
Notifications
You must be signed in to change notification settings - Fork 396
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 1 commit
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
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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,55 @@ | ||
from selenium.webdriver.common.by import By | ||
from behave import given, when, then | ||
from time import sleep | ||
|
||
|
||
SEARCH_INPUT = (By.ID, 'search') | ||
SEARCH_BTN = (By.XPATH, "//button[@data-test='@web/Search/SearchButton']") | ||
HEADER_LINKS = (By.CSS_SELECTOR, "a[id*='utilityNav']") | ||
ADD_TO_CART_BTN = (By.CSS_SELECTOR, "[id*='addToCartButton']") | ||
SIDE_NAV_ADD_TO_CART_BTN = (By.CSS_SELECTOR, "[aria-label*='Add to cart']") | ||
OPEN_CART_PAGE = (By.CSS_SELECTOR, "a[class*='ButtonSecondary']") | ||
CART_SUMMARY = (By.CSS_SELECTOR, "span[class*='CartSummary']") | ||
CART_ITEM_TITLE = (By.CSS_SELECTOR, "[data-test*='cartItem-title']") | ||
|
||
|
||
@given('Open Target main page') | ||
def open_target(context): | ||
context.driver.get('https://www.target.com/') | ||
|
||
|
||
@when("Search for {item}") | ||
def search_product(context, item): | ||
context.driver.find_element(*SEARCH_INPUT).send_keys(item) | ||
context.driver.find_element(*SEARCH_BTN).click() | ||
sleep(6) | ||
|
||
|
||
@when('Click on Add to Cart button') | ||
def click_add_cart(context): | ||
context.driver.find_element(*ADD_TO_CART_BTN).click() | ||
|
||
|
||
@when('Confirm Add to Cart button from side navigation') | ||
def side_nav_click_add_to_cart(context): | ||
context.driver.find_element(*SIDE_NAV_ADD_TO_CART_BTN).click() | ||
sleep(2) | ||
|
||
|
||
@when('Open cart page') | ||
def open_cart(context): | ||
context.driver.get('https://www.target.com/cart') | ||
sleep(3) | ||
|
||
|
||
@then('Verify cart has correct product') | ||
def verify_product_name(context): | ||
actual_name = context.driver.find_element(*CART_ITEM_TITLE).text | ||
expected_product_name = 'cups' | ||
assert expected_product_name in actual_name.lower(), f'Expected {expected_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}' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
from selenium.webdriver.common.by import By | ||
from behave import given, then | ||
from time import sleep | ||
|
||
VERIFY_CELLS_SHOWN = (By.CSS_SELECTOR, "[data-component-title*='BaseDrivers'] div.cell-item-content") | ||
|
||
|
||
@given('Open Target Circle page') | ||
def open_target(context): | ||
context.driver.get('https://www.target.com/circle') | ||
|
||
|
||
@then('Verify there are cells shown') | ||
def verify_cells_shown(context): | ||
cells = context.driver.find_elements(*VERIFY_CELLS_SHOWN) | ||
assert len(cells) > 0, "No cells are shown on the page" | ||
sleep(6) |
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,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 | ||
|
||
|
||
driver_path = ChromeDriverManager().install() | ||
|
||
|
||
service = Service(driver_path) | ||
driver = webdriver.Chrome(service=service) | ||
driver.maximize_window() | ||
|
||
|
||
driver.get('https://www.target.com/') | ||
|
||
|
||
driver.find_element(By.ID, 'search').send_keys('bicycle') | ||
|
||
driver.find_element(By.XPATH, "//button[@data-test='@web/Search/SearchButton']").click() | ||
|
||
sleep(6) | ||
|
||
|
||
actual_text = driver.find_element(By.XPATH, "//div[@data-test='resultsHeading']").text | ||
assert 'coffee' in actual_text, f'Error! Text coffee not in {actual_text}' | ||
|
||
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,13 @@ | ||
Feature: Add Product | ||
|
||
Scenario: User can add a product to cart | ||
Given Open Target main page | ||
When Search for mug | ||
And Click on Add to Cart button | ||
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 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 Circle Page Verification | ||
|
||
|
||
Scenario: Verify the benefits cells are shown | ||
Given Open Target Circle page | ||
Then Verify there are cells shown | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
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.
great work with
find_elements
👍