def setup(self, driver_setup): self.login_page = LoginPage(driver_setup) self.results_page = ResultsPage(driver_setup) self.product_page = ProductPage(driver_setup) self.cart = CartPage(driver_setup) self.delivery_page = DeliveryPage(driver_setup) self.product = "jeans"
class SearchTest(unittest.TestCase): @pytest.fixture(autouse=True) def object_setup(self): self.front_page = FrontPage(self.driver) self.results_page = ResultsPage(self.driver) self.status = Status(self.driver) @pytest.mark.run(order=7) def test_no_results(self): self.front_page.navigate_to_front_page() self.front_page.search_items('askldfjaslkdfjklsaf') result = self.results_page.verify_search_no_results() self.status.mark(result, 'Search items with no results test') @pytest.mark.run(order=8) def test_search_item_dropdown(self): self.front_page.navigate_to_front_page() self.front_page.search_item_dropdown('Printed Summer Dress') result = self.results_page.verify_search_item_dropdown( 'Printed Summer Dress') self.status.mark(result, 'Search an item via dropdown test') @pytest.mark.run(order=9) def test_search_results(self): self.front_page.navigate_to_front_page() self.front_page.search_items('printed') result = self.results_page.verify_search_results('printed') self.status.mark(result, 'Search results test')
def test_search_main_page(self): hp = HomePage(self.driver) hp.go() hp.search_directly("test") rp = ResultsPage(self.driver) rp.wait(2) count = rp.get_results_count() assert count > 0
def test_neg_search_main_page(self): hp = HomePage(self.driver) hp.go() hp.search_directly("negative testing :)") rp = ResultsPage(self.driver) rp.wait(2) count = rp.get_results_count() assert count == 0
def test_suggests_contains_search_request(driver, search_query): search_page = MailSearchPage(driver, url=URL.main_search_url) search_page.transfer() search_page.wait_for_load() search_page.set_search_field(search_query) suggestions = search_page.get_suggestions_text() assert suggestions, 'Саджесты не обнаружены' if not all(search_query in i for i in suggestions): allure_attach_json(suggestions) pytest.fail('В некоторых саджестах не обнаружен поисковый запрос') search_page.select_suggestion_by_text(suggestions[3]) results_page = ResultsPage(driver) results_page.wait_for_load() assert results_page.has_results()
class CartTest(unittest.TestCase): @pytest.fixture(autouse=True) def object_setup(self): self.front_page = FrontPage(self.driver) self.results_page = ResultsPage(self.driver) self.cart_page = CartPage(self.driver) self.status = Status(self.driver) @pytest.fixture() def clear_cart_teardown(self): yield self.results_page.navigate_to_cart_page() self.cart_page.remove_all_items_from_cart() @pytest.mark.run(order=10) @pytest.mark.usefixtures('clear_cart_teardown') def test_add_items_to_cart(self): self.front_page.navigate_to_front_page() self.front_page.search_items('printed') self.results_page.add_items_to_cart([1, 3, 5]) result1 = self.results_page.verify_cart_modal_with_correct_quantity() self.status.mark(result1, 'Add multiple products to cart test') @pytest.mark.run(order=11) def test_items_in_results_page_and_cart_page(self): self.front_page.navigate_to_front_page() self.front_page.search_items('printed') self.results_page.add_items_to_cart([1, 3, 5]) items_in_results_page = self.results_page.items_in_cart items_in_cart_page = self.cart_page.get_items_in_cart(False) result = items_in_results_page == items_in_cart_page self.status.mark( result, 'Matching items in cart from results page and cart page test') @pytest.mark.run(order=12) def test_remove_an_item_from_cart(self): self.results_page.navigate_to_cart_page() self.driver.implicitly_wait(5) self.cart_page.remove_an_item_from_cart(2) result = self.cart_page.verify_item_is_removed_from_cart() self.status.mark(result, 'Remove an item from cart test') @pytest.mark.run(order=13) def test_remove_all_items_from_cart(self): self.cart_page.remove_all_items_from_cart() result = self.cart_page.verify_cart_is_empty() self.status.mark(result, 'Remove all items from cart test')
def test_to_results_by_click(self, search_page): search_page.input_search('pyth') suggestion = search_page.get_suggestions()[0] search_text = suggestion.text suggestion.click() ResultsPage(search_page._driver).get_results() assert search_text in search_page.title
def enter_user_info(self, name, email, birthdate, address): self.get_field_name().send_keys(name) self.get_field_email().send_keys(email) self.get_field_birthdate().send_keys(birthdate) self.get_field_address().send_keys(address) self.get_submit_button().click() return ResultsPage(self.driver)
def __init__(self, driver): self.driver = driver self.page = Page(self.driver) self.top_nav_menu = TopNavMenu(self.driver) # self.search_results_page = SearchResults(self.driver) self.main_page = MainPage(self.driver) self.results_page = ResultsPage(self.driver) self.hamburger_menu_page = HamburgerMenuPage(self.driver) self.product_page = Product(self.driver)
def __init__(self, driver): self.driver = driver self.page = Page(self.driver) self.topbanner = TopBanner(self.driver) self.results_page = ResultsPage(self.driver) self.latest_prod = LatestProd(self.driver) self.product = Product(self.driver) self.browse_cat = BrowseCat(self.driver) self.top_nav_menu = TopNavMenu(self.driver) self.footer_page = Footer(self.driver)
class TestProductPage: @pytest.fixture() def setup(self, driver_setup): self.results_page = ResultsPage(driver_setup) self.product_page = ProductPage(driver_setup) self.login_page = LoginPage(driver_setup) self.wish = WishlistPage(driver_setup) self.product = "jeans" @pytest.mark.tcid15 def test_add_product_to_cart_as_user(self, setup): self.login_page.goto() self.login_page.login() self.results_page.goto_product(self.product) self.product_page.add_to_bag(select_type="dropdown") assert self.product_page.verify_added_to_bag() if AssertionError: self.login_page.driver.take_screenshot( name="test_add_product_to_cart_as_user") @pytest.mark.tcid16 def test_add_product_to_wishlist_as_user(self, setup): self.login_page.goto() self.login_page.login() self.results_page.goto_product(self.product) product_name = self.product_page.get_product_title() self.product_page.add_to_wishlist(select_type="dropdown") assert self.wish.verify_product_in_wishlist(product_name) if AssertionError: self.login_page.driver.take_screenshot( name="test_add_product_to_wishlist_as_user") @pytest.mark.tcid17 def test_add_product_to_cart_as_guest(self, setup): self.results_page.goto_product(self.product) self.product_page.add_to_bag(select_type="dropdown") assert self.product_page.verify_added_to_bag() if AssertionError: self.login_page.driver.take_screenshot( name="test_add_product_to_wishlist_as_user") @pytest.mark.tcid18 def test_guest_must_login_to_wishlist_product(self, setup): self.results_page.goto_product(self.product) self.product_page.add_to_wishlist(select_type="dropdown") assert self.product_page.verify_login_prompt() if AssertionError: self.login_page.driver.take_screenshot( name="test_guest_must_login_to_wishlist_product")
class TestAddDeliveryAddress(unittest.TestCase): root = os.path.dirname(os.path.dirname(__file__)) data_path = os.path.join(root, "..", "test_data", "AddressRecords.csv") @pytest.fixture() def setup(self, driver_setup): self.login_page = LoginPage(driver_setup) self.results_page = ResultsPage(driver_setup) self.product_page = ProductPage(driver_setup) self.cart = CartPage(driver_setup) self.delivery_page = DeliveryPage(driver_setup) self.product = "jeans" @pytest.fixture() def preconditions(self, setup): if not self.login_page.verify_logged_in(): self.login_page.goto() self.login_page.login() self.results_page.goto_product(self.product) self.product_page.add_to_bag(select_type="dropdown") self.cart.goto() self.cart.goto_checkout_page() yield self.delivery_page.go_back_to_home_page() @pytest.mark.tcid25 @data(*getCSVData(data_path)) @unpack @pytest.mark.usefixtures("setup", "preconditions") def test_add_valid_delivery_details(self, fullAddress, Postcode, PhoneNum): self.delivery_page.enter_full_delivery_details(phone=PhoneNum, postcode=Postcode, full_address=fullAddress) assert self.delivery_page.verify_valid_delivery_details() if AssertionError: self.delivery_page.driver.take_screenshot(name="test_add_valid_delivery_details")
class TestPayWithCreditCard(unittest.TestCase): root = os.path.dirname(os.path.dirname(__file__)) data_path = os.path.join(root, "..", "test_data", "CCRecords.csv") @pytest.fixture() def setup(self, driver_setup): self.login_page = LoginPage(driver_setup) self.results_page = ResultsPage(driver_setup) self.product_page = ProductPage(driver_setup) self.cart = CartPage(driver_setup) self.payment_page = PaymentPage(driver_setup) self.delivery_page = DeliveryPage(driver_setup) self.product = "jeans" @pytest.fixture() def preconditions(self, setup): self.login_page.goto() self.login_page.login() self.results_page.goto_product(self.product) self.product_page.add_to_bag(select_type="dropdown") self.cart.goto() self.cart.goto_checkout_page() self.delivery_page.enter_full_delivery_details() @data(*getCSVData(data_path)) @unpack @pytest.mark.tcid30 @pytest.mark.usefixtures("setup", "preconditions") def test_pay_with_valid_card(self, ccNum, ccCVV, ccExp): self.payment_page.place_order(payment_options="card", curd_num=ccNum, expiry_date=ccExp, cvv=ccCVV) assert self.payment_page.verify_successful_payment() if AssertionError: self.delivery_page.driver.take_screenshot(name="test_pay_with_valid_card")
def test_create_user(self): test_user = '******' + str(randint(0, 100000)) create_user_page = CreateUserPage(self.driver) create_user_page.enter_user_info(test_user, '*****@*****.**', '10/10/2000', '444') results_page = ResultsPage(self.driver) self.assertEqual(results_page.message_text, 'User {} created'.format(test_user)) create_user_page.go_to_page(self) users_page = UsersListPage(self.driver) self.assertTrue( users_page.check_user_exists(test_user, '*****@*****.**', '10/10/2000', '444'))
def test_to_results_by_arrow(self, search_page): search_page.input_search('pyth') search_text = search_page.navigate_over_suggestions(Keys.DOWN).text search_page.get_element(search_page.SEARCH_FIELD).submit() ResultsPage(search_page._driver).get_results() assert search_text in search_page.title
from behave import given, when, then from selenium.webdriver.android import webdriver from utils import Utils from pages.form_page import FormPage from pages.results_page import ResultsPage from selenium import webdriver from nose.tools import assert_equal from browser import Browser from allure_behave.hooks import allure_report from nose.tools import assert_equal from selenium.webdriver.common.keys import Keys utils=Utils() form_page= FormPage() results_page=ResultsPage() #from browser import Browser #browser= Browser() @given(u'que acesso o site da Globo') def step_impl(context): utils.navegar('https://homologacao.imprensa.globo.com') @given(u'clico no botão Novo Cadastro') def step_impl(context): Browser.driver.find_element_by_link_text('Novo Cadastro').click() @when(u'Preencho o Formulario')
def go_to_results(self): form = self.get_element(self.SEARCH_FIELD) form.send_keys(Keys.RIGHT) form.submit() return ResultsPage(self._driver)
def testProductSearch(self, products): hp = HomePage(self.driver) rp = ResultsPage(self.driver) rp.search_product(products) #test z elementem losowości: losuje 1 wartość z listy poniżej i wyszukuje w sklepie: # rp.search_product( # (random.choice(["Drony", "Java Script", "Java", "Roboty", "Raspberry"]))) rp.search_product2() rp.search_product_results() rp.submit_results() rp.product_sorting() rp.choose_products() rp.close_cookies() rp.order_click() rp.verify_site_order() rp.sum_of_products() suma = rp.sum_of_products() zam2 = rp.client_order() self.assertEqual(suma, zam2, "Ceny nie są zgodne.") rp.clear_basket()
def object_setup(self): self.front_page = FrontPage(self.driver) self.results_page = ResultsPage(self.driver) self.cart_page = CartPage(self.driver) self.status = Status(self.driver)
def setup(self, driver_setup): self.results_page = ResultsPage(driver_setup) self.product_page = ProductPage(driver_setup) self.login_page = LoginPage(driver_setup) self.wish = WishlistPage(driver_setup) self.product = "jeans"
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.base_selenium = BaseSelenium() self.search_page = SearchPage() self.results_page = ResultsPage()
def test_inline_suggest(self, search_page): search_page.input_search('pyth') search_page.wait_text(search_page.INLINE_SUGGEST, 'python') search_page.go_to_results() ResultsPage(search_page._driver).get_results() assert 'python' in search_page.title.lower()
def test_user(self, browser): link = "https://www.booking.com/" mp = MainPage(browser, link) mp.setup() mp.choose_city() result_page = ResultsPage(browser, browser.current_url) result_page.is_hotels_listed() result_page.is_calendar_opened() result_page.price_or_status_are_not_displayed() result_page.calendar_opened_after_show_btn() result_page.check_booking_prices()
def setup(driver_setup): results_page = ResultsPage(driver_setup) return results_page