-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ def chrome_options(): | |
if not gpu: | ||
_chrome_options.add_argument("--disable-gpu") | ||
if window_size: | ||
_chrome_options.add_argument("--window-size={}".format(window_size)) | ||
_chrome_options.add_argument(f"--window-size={window_size}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
if headless: | ||
_chrome_options.add_argument("--headless") | ||
_chrome_options.add_argument("--load-images=no") | ||
|
@@ -51,7 +51,7 @@ def __init__(self, driver: WebDriver, base_url: str) -> None: | |
self.base_url = base_url | ||
|
||
def wait(self, parent_elem: WebElement = None, timeout: int = 10) -> WebDriverWait: | ||
parent = parent_elem if parent_elem else self.driver | ||
parent = parent_elem or self.driver | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
return WebDriverWait(parent, timeout) | ||
|
||
def open(self, url: str, reopen: bool = False) -> None: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,18 @@ | |
@when("I sort the products by {sort_order} order") | ||
def step_impl_1(context: SauceDemoContext, sort_order: str): | ||
sort_option = context.driver.find_element_by_xpath( | ||
"//option[contains(text(),'{}')]".format(sort_order) | ||
f"//option[contains(text(),'{sort_order}')]" | ||
) | ||
|
||
Comment on lines
-13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
sort_option.click() | ||
|
||
|
||
@then("the products page is sorted in {sort_order} order") | ||
def step_impl_2(context: SauceDemoContext, sort_order: str): | ||
product_sort_container = context.driver.find_element_by_xpath( | ||
"//span[contains(text(),'{}')]".format(sort_order) | ||
f"//span[contains(text(),'{sort_order}')]" | ||
) | ||
|
||
Comment on lines
-21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
expect(product_sort_container.text.lower()).to(equal(sort_order.lower())) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,8 +41,9 @@ def step_impl_5(context: SauceDemoContext, page_name: str): | |
# create a dictionary for relative url reference | ||
page_dict = {"login": "", "products": "inventory.html", "cart": "cart.html"} | ||
expected_url = parse.urljoin( | ||
context.browser_data["url"], "{}".format(page_dict[page_name.lower()]) | ||
context.browser_data["url"], f"{page_dict[page_name.lower()]}" | ||
) | ||
|
||
Comment on lines
-44
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
context.wait.until(ec.url_matches(expected_url)) | ||
|
||
|
||
|
@@ -87,25 +88,26 @@ def step_impl_9(context: SauceDemoContext, sidebar_link: str): | |
ec.visibility_of_element_located( | ||
( | ||
By.XPATH, | ||
"//a[@class='bm-item menu-item' " | ||
"and contains(text(),'{}')]".format(sidebar_link), | ||
f"//a[@class='bm-item menu-item' and contains(text(),'{sidebar_link}')]", | ||
) | ||
) | ||
) | ||
|
||
Comment on lines
-90
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
selected_sidebar_link.click() | ||
|
||
|
||
@when("I enter an incorrect password") | ||
def step_impl_10(context: SauceDemoContext): | ||
password = context.driver.find_element_by_xpath("//input[@id='password']") | ||
password.send_keys("{}{}".format(context.user["password"], time.time())) | ||
password.send_keys(f'{context.user["password"]}{time.time()}') | ||
Comment on lines
-101
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
@then("this error message is displayed") | ||
def step_impl_11(context: SauceDemoContext): | ||
error_message = context.wait.until( | ||
ec.presence_of_element_located( | ||
(By.XPATH, '//h3[contains(text(),"{}")]'.format(context.text.strip())) | ||
(By.XPATH, f'//h3[contains(text(),"{context.text.strip()}")]') | ||
) | ||
) | ||
|
||
Comment on lines
-108
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
expect(error_message.text).to(equal(context.text.strip())) |
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.
Function
after_scenario
refactored with the following changes:last-if-guard
)use-fstring-for-formatting
)