-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,4 @@ | ||
#!/usr/bin/env python | ||
|
||
from behave.__main__ import main as behave_main | ||
behave_main('features') |
This file contains 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 @@ | ||
[behave] | ||
stderr_capture = False | ||
stdout_capture = False | ||
|
||
[behave.userdata] | ||
browser = chrome | ||
homepage_url = https://en.wikipedia.org/wiki/Main_Page |
This file contains 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,14 @@ | ||
from selenium import webdriver | ||
from webdriver_manager.chrome import ChromeDriverManager | ||
from pages.base_page import BasePage | ||
|
||
|
||
def before_all(context): | ||
browser = context.config.userdata['browser'] | ||
if browser == "chrome": | ||
driver = BasePage(webdriver.Chrome(ChromeDriverManager().install())) | ||
context.driver = driver | ||
context.homepage_url = context.config.userdata['homepage_url'] | ||
|
||
def after_all(context): | ||
context.driver.quit() |
This file contains 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,33 @@ | ||
from behave import given, when, then | ||
from hamcrest import assert_that, equal_to | ||
|
||
from pages.locators import * | ||
from pages.home_page import HomePage | ||
from pages.search_page import SearchPage | ||
|
||
|
||
@given("User is on wikipedia Homepage") | ||
def step_impl(context): | ||
""" | ||
:type context: behave.runner.Context | ||
""" | ||
context.driver.open(context.homepage_url) | ||
|
||
|
||
@when('User searches "{word}"') | ||
def step_impl(context, word): | ||
""" | ||
:type context: behave.runner.Context | ||
""" | ||
homepage = HomePage(context.driver) | ||
homepage.set_search_query(word) | ||
homepage.search() | ||
|
||
|
||
@then('Title of the page should be "{word}"') | ||
def step_impl(context, word): | ||
""" | ||
:type context: behave.runner.Context | ||
""" | ||
search_page = SearchPage(context.driver) | ||
assert_that(search_page.heading_text(), equal_to(word)) |
This file contains 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,6 @@ | ||
Feature: Wikipedia landing page feature | ||
|
||
Scenario: Launch wikipedia application | ||
Given User is on wikipedia Homepage | ||
When User searches "Design Pattern" | ||
Then Title of the page should be "Design pattern" |
Empty file.
This file contains 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,20 @@ | ||
# Base Page | ||
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._timeout = 10 | ||
self._driver_wait = WebDriverWait(self._driver, self._timeout) | ||
|
||
def open(self, url): | ||
self._driver.get(url) | ||
self._driver.maximize_window() | ||
|
||
# Add Explicit Wait to find_element API | ||
def find_element(self, *locator): | ||
return self._driver_wait.until(EC.visibility_of_element_located(locator)) | ||
|
||
def quit(self): | ||
return self._driver.quit() |
This file contains 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,10 @@ | ||
from pages.base_page import BasePage | ||
from pages.locators import HomePageLocators | ||
|
||
class HomePage(BasePage): | ||
|
||
def set_search_query(self, query): | ||
self.find_element(*HomePageLocators.SEARCH_CONTAINER).send_keys(query) | ||
|
||
def search(self): | ||
self.find_element(*HomePageLocators.SEARCH_BUTTON).click() |
This file contains 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,8 @@ | ||
from selenium.webdriver.common.by import By | ||
|
||
class HomePageLocators(): | ||
SEARCH_CONTAINER = (By.ID, "searchInput") | ||
SEARCH_BUTTON = (By.ID, "searchButton") | ||
|
||
class SearchPageLocators(): | ||
HEADING = (By.ID, "firstHeading") |
This file contains 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 @@ | ||
from pages.base_page import BasePage | ||
from pages.locators import SearchPageLocators | ||
|
||
class SearchPage(BasePage): | ||
|
||
def heading_text(self): | ||
return self.find_element(*SearchPageLocators.HEADING).text |