Exemple #1
0
class UnitTesting(unittest.TestCase):
    def setUp(self):
        # Selenium support for PhantomJS has been deprecated, please use headless
        # self.driver = webdriver.PhantomJS('drivers/phantomjs')

        options = webdriver.ChromeOptions()
        options.add_argument('headless')
        self.driver = webdriver.Chrome('drivers/chromedriver', options=options)
        self.driver.get('http://newtours.demoaut.com/')
        self.page_index = PageIndex(driver=self.driver)
        self.flight_page = FlightPage(driver=self.driver)
        self.path = 'screenshots/' + str(datetime.datetime.now()) + '/'
        if not os.path.exists(self.path):
            os.makedirs(self.path, 0o0755)

    def test_dropdown(self):
        self.page_index.register()
        country_dropdown = self.flight_page.select_country()
        self.driver.get_screenshot_as_file(self.path + 'select_country.png')
        self.assertEqual(country_dropdown.first_selected_option.text.strip(),
                         'ANDORRA')

    def test_login(self):
        self.page_index.login(username='******', password='******')

        link_registration_form = self.driver.find_element_by_link_text(
            'registration form')
        self.driver.save_screenshot(self.path + 'login.png')
        self.assertEqual(link_registration_form.text, 'registration form')

    def tearDown(self):
        self.driver.close()
        self.driver.quit()
Exemple #2
0
class TestPageLogin(unittest.TestCase):
    """Método con las pre-condiciones"""

    def setUp(self):
        self.basePage = BasePage()
        self.driver = webdriver.Chrome(self.basePage.driver)
        self.driver.get(self.basePage.base_url)
        self.driver.implicitly_wait(5)
        self.driver.maximize_window()
        self.login = PageLogin(self.driver)
        self.indexPage = PageIndex(self.driver)
        self.itemPage = ResultCases(self.driver)
        self.buyPage = PageBuy(self.driver)
        self.createdAccount = PageCreateAccount(self.driver)
        self.myAccount = PageMyAccount(self.driver)
        self.utilsFunctions = FunctionsUtils()
        self.userStatic = StaticUserSigIn()

    def test_title_of_page(self):
        """Este tests verfica que después de ingresar el mail y presionar el botón crear cuenta, efectivamente
        se pase a la sección AUTHENTICATION"""

        self.indexPage.push_sign_in()
        self.login.send_mail_box(self.utilsFunctions.generate_email())
        self.login.push_create_an_account()
        self.assertEqual('AUTHENTICATION', self.createdAccount.return_title_of_create_authentication())

    def test_sign_in_complete_verify_name_of_user_and_title_banner_my_account(self):
        """Este tests realiza un registro completo y posteriormente valida que el nombre de usuario
        coincida efectivamente con el creado y que se esté en la página MY ACCOUNT"""

        self.indexPage.push_sign_in()
        self.login.send_mail_box(self.utilsFunctions.generate_email())
        self.login.push_create_an_account()
        self.createdAccount.select_button_radio_gender()
        self.createdAccount.sender_first_name(self.userStatic.first_name_user)
        self.createdAccount.sender_last_name(self.userStatic.last_name_user)
        self.createdAccount.click_in_mail_for_confirmation()
        self.createdAccount.sender_password(self.userStatic.password_user)
        self.createdAccount.select_day_month_and_year_with_value('3', '4', '1994')
        self.createdAccount.select_check_box_newsletter()
        self.createdAccount.sender_company_address_and_city('Software', 'América', 'San Martín')
        self.createdAccount.select_state_with_value('12')
        self.createdAccount.sender_postal_code('00000')
        self.createdAccount.select_country_with_value('21')
        self.createdAccount.complete_additional_information('Aditional Information, Great!')
        self.createdAccount.number_phone_mobile_and_home_phone(self.utilsFunctions.generate_number_phone(), self.
                                                               utilsFunctions.generate_number_phone())
        self.createdAccount.sender_address_aditional_alias('This is my address!')
        self.createdAccount.click_button_register()
        name_user_register = self.myAccount.return_text_user_register()
        title_register_successfully = self.myAccount.return_text_of_banner()
        self.assertEqual('Lorena Pérez', name_user_register)
        self.assertTrue('MY ACCOUNT' in title_register_successfully)

    ''' Método con las post-condiciones'''

    def tearDown(self):
        self.driver.close()
        self.driver.quit()
Exemple #3
0
 def setUp(self):
     self.basePage = BasePage()
     self.driver = webdriver.Chrome(self.basePage.driver)
     self.driver.get(self.basePage.base_url)
     self.driver.implicitly_wait(5)
     self.driver.maximize_window()
     self.indexPage = PageIndex(self.driver)
     self.resultPage = ResultCases(self.driver)
     self.buyPage = PageBuy(self.driver)
Exemple #4
0
 def setUp(self):
     self.basePage = BasePage()
     self.driver = webdriver.Chrome(self.basePage.driver)
     self.driver.get(self.basePage.base_url)
     self.driver.implicitly_wait(5)
     self.driver.maximize_window()
     self.indexPage = PageIndex(self.driver)
     self.resultPage = ResultCases(self.driver)
     self.buyPage = PageBuy(self.driver)
     self.cartSummary = PageCartSummary(self.driver)
     self.login = PageLogin(self.driver)
     self.userStatic = StaticUserRegistered()
Exemple #5
0
    def setUp(self):
        # Selenium support for PhantomJS has been deprecated, please use headless
        # self.driver = webdriver.PhantomJS('drivers/phantomjs')

        options = webdriver.ChromeOptions()
        options.add_argument('headless')
        self.driver = webdriver.Chrome('drivers/chromedriver', options=options)
        self.driver.get('http://newtours.demoaut.com/')
        self.page_index = PageIndex(driver=self.driver)
        self.flight_page = FlightPage(driver=self.driver)
        self.path = 'screenshots/' + str(datetime.datetime.now()) + '/'
        if not os.path.exists(self.path):
            os.makedirs(self.path, 0o0755)
Exemple #6
0
 def setUp(self):
     self.basePage = BasePage()
     self.driver = webdriver.Chrome(self.basePage.driver)
     self.driver.get(self.basePage.base_url)
     self.driver.implicitly_wait(5)
     self.driver.maximize_window()
     self.login = PageLogin(self.driver)
     self.indexPage = PageIndex(self.driver)
     self.itemPage = ResultCases(self.driver)
     self.buyPage = PageBuy(self.driver)
     self.createdAccount = PageCreateAccount(self.driver)
     self.myAccount = PageMyAccount(self.driver)
     self.utilsFunctions = FunctionsUtils()
     self.userStatic = StaticUserSigIn()
Exemple #7
0
 def step_impl(self):
     PageIndex.click_log_out_link(self)
Exemple #8
0
 def step_impl(self):
     PageIndex.send_username_registered(self,self.username)
     PageIndex.send_password_registered(self,self.password)
Exemple #9
0
 def step_impl(self):
     PageIndex.click_sign_up_link(self)
     print('Click on sign up ')
Exemple #10
0
 def step_impl(self):
     text_of_link = PageIndex.get_name_user_of_link(self)
     assert_equal('Welcome '+self.username,text_of_link)
Exemple #11
0
 def step_impl(self):
     PageIndex.click_log_in_button(self)
Exemple #12
0
 def step_impl(self):
     PageIndex.click_sign_up_button(self)
Exemple #13
0
 def step_impl(self):
     PageIndex.send_username_login(self, self.username)
     PageIndex.send_password_login(self, self.password)
Exemple #14
0
 def step_impl(self, text="Sony vaio i5"):
     PageIndex.click_link_product(self, text)
Exemple #15
0
 def step_impl(self, mensage='Sign up successful.'):
     text_alert = PageIndex.get_text_alert_popup(self)
     assert_equal(text_alert,mensage)
Exemple #16
0
class TestSearchCases(unittest.TestCase):
    """Método con las pre-condiciones"""
    def setUp(self):
        self.basePage = BasePage()
        self.driver = webdriver.Chrome(self.basePage.driver)
        self.driver.get(self.basePage.base_url)
        self.driver.implicitly_wait(5)
        self.driver.maximize_window()
        self.indexPage = PageIndex(self.driver)
        self.resultPage = ResultCases(self.driver)
        self.buyPage = PageBuy(self.driver)

    def test_search_no_element(self):
        """ ##Test #1 Este tests busca un elemento inválido y verifica que la página
        devuelva un mensaje de error error"""

        self.indexPage.search('Manzana')
        self.assertEqual(self.resultPage.get_text(),
                         'No results were found for your search "Manzana"')

    def test_search_element_valid(self):
        """ ##Test #2
         Este tests busca un elemento válido y verifica que aparezca correctamente el nombre del elemento"""

        self.indexPage.search('Dress')
        self.assertTrue('DRESS' in self.resultPage.return_section_title())

    def test_search_element_valid_two(self):
        """##Test #3 Este tests busca un
         elemento válido y verifica que aparezca correctamente el nombre del elemento"""

        self.indexPage.search('T-Shirt')
        self.assertTrue('T-SHIRT' in self.resultPage.return_section_title())

    def test_button_orange(self):
        """##Test #4
        Este tests busca un elemento, elige el color naranja, agrega 8 y verifica que el número coincida"""

        self.indexPage.search('T-Shirt')
        self.resultPage.click_color()
        self.buyPage.push_quantity('5')
        self.buyPage.add_elements(3)
        number_of_elements = self.buyPage.get_number_of_elements()
        self.assertEqual(number_of_elements, '8')

    def test_list_product_selection(self):
        """##Test #5 Este tests toma diferentes valores de la lista de métodos
        de filtrado de una búsqueda"""

        self.indexPage.search('T-Shirt')
        self.resultPage.product_list_by_select('Product Name: A to Z')
        self.resultPage.product_list_by_value('reference:desc')
        self.resultPage.product_list_by_index(3)

    def test_check_phone_number(self):
        """##Test #6 Este tests checkea el número de teléfono de la página"""

        phone_number = self.indexPage.return_phone_number_of_banner()
        self.assertEqual(phone_number, '0123-456-789')

    ''' Método con las post-condiciones'''

    def tearDown(self):
        self.driver.close()
        self.driver.quit()
Exemple #17
0
 def step_impl(self, number_phone=r'[^0-9]'):
     self.phone_number_of_index_page = PageIndex.return_phone_number_of_banner(
         self)
     print('The number phone is: ' + self.phone_number_of_index_page)
     assert self.phone_number_of_index_page == number_phone, 'Not macht'
Exemple #18
0
 def step_impl(self):
     PageIndex.push_sign_in(self)
Exemple #19
0
class TestPagePurchases(unittest.TestCase):
    """Método con las pre-condiciones"""

    def setUp(self):
        self.basePage = BasePage()
        self.driver = webdriver.Chrome(self.basePage.driver)
        self.driver.get(self.basePage.base_url)
        self.driver.implicitly_wait(5)
        self.driver.maximize_window()
        self.indexPage = PageIndex(self.driver)
        self.resultPage = ResultCases(self.driver)
        self.buyPage = PageBuy(self.driver)
        self.cartSummary = PageCartSummary(self.driver)
        self.login = PageLogin(self.driver)
        self.userStatic = StaticUserRegistered()

    def test_product_successfully_added_to_cart_text(self):
        """Este tests valida que un producto sea agregado correctamente al carrito de compras"""

        self.indexPage.search('T-Shirt')
        self.resultPage.click_color()
        self.buyPage.push_add_to_cart()
        text_successfully_add_product = self.buyPage.get_text_successfully_add_product_text()
        self.assertTrue(text_successfully_add_product in 'Product successfully added to your shopping cart')

    def test_title_text_shopping_cart_summary(self):
        """Este tests verifica título y cantidad de productos agregados al carrito"""

        self.indexPage.search('T-Shirt')
        self.resultPage.click_color()
        self.buyPage.push_add_to_cart()
        self.buyPage.push_button_proceed_to_checkout()
        text_title_shopping_cart = self.cartSummary.get_text_of_title_shopping_cart()
        self.assertEqual('SHOPPING-CART SUMMARY\nYour shopping cart contains: 1 Product', text_title_shopping_cart)

    def test_number_of_price_total_shopping_cart(self):
        """Este tests verifica que el precio del producto sea correcto"""

        self.indexPage.search('T-Shirt')
        self.resultPage.click_color()
        self.buyPage.push_add_to_cart()
        self.buyPage.push_button_proceed_to_checkout()
        price_total = self.cartSummary.get_number_of_price_total()
        self.assertEqual('$18.51', price_total)

    def test_title_text_addresses(self):
        """Este tests primero ingresa con un usuario válido y después verifica que se pase
        efectivamente a la página ADDRESSES y envía un texto al campo If you would like to add a comment about your
        order, please write it in the field below."""

        self.indexPage.push_sign_in()
        self.login.send_mail_user_registered(self.userStatic.email_user_registered)
        self.login.send_password_user_registered(self.userStatic.password_user_registered)
        self.login.push_button_sign_in_registered()
        self.indexPage.search('T-Shirt')
        self.resultPage.click_color()
        self.buyPage.push_add_to_cart()
        self.buyPage.push_button_proceed_to_checkout()
        self.cartSummary.push_button_proceed_to_checkout_address()
        self.cartSummary.send_text_in_box_comment_of_address('My adress')
        title_address = self.cartSummary.get_text_of_title_address()
        self.assertEqual('ADDRESSES', title_address)

    def test_page_of_shipping_delivery(self):
        """Este tests verifica que el título de la sección shipping y el precio de delivery sean correctos"""

        self.indexPage.push_sign_in()
        self.login.send_mail_user_registered(self.userStatic.email_user_registered)
        self.login.send_password_user_registered(self.userStatic.password_user_registered)
        self.login.push_button_sign_in_registered()
        self.indexPage.search('T-Shirt')
        self.resultPage.click_color()
        self.buyPage.push_add_to_cart()
        self.buyPage.push_button_proceed_to_checkout()
        self.cartSummary.push_button_proceed_to_checkout_address()
        self.cartSummary.push_button_proceed_to_checkout_shipping()
        self.cartSummary.click_of_check_box_terms_and_conditions()
        title_of_page = self.cartSummary.get_text_of_title_shipping()
        price_of_delivery = self.cartSummary.get_text_price_of_delivery_shipping()
        self.assertEqual('SHIPPING', title_of_page)
        self.assertEqual('$2.00', price_of_delivery)

    def test_page_of_payment_product_title_and_finally_price_total(self):
        """Este tests verifica que efectivamete se haya pasado a la página de pago y que el
        precio total sea el correcto"""

        self.indexPage.push_sign_in()
        self.login.send_mail_user_registered(self.userStatic.email_user_registered)
        self.login.send_password_user_registered(self.userStatic.password_user_registered)
        self.login.push_button_sign_in_registered()
        self.indexPage.search('T-Shirt')
        self.resultPage.click_color()
        self.buyPage.push_add_to_cart()
        self.buyPage.push_button_proceed_to_checkout()
        self.cartSummary.push_button_proceed_to_checkout_address()
        self.cartSummary.push_button_proceed_to_checkout_shipping()
        self.cartSummary.click_of_check_box_terms_and_conditions()
        self.cartSummary.push_button_proceed_to_checkout_payment()
        title_payment = self.cartSummary.get_text_of_title_payment()
        price_finally = self.cartSummary.get_text_price_total_finally()
        self.assertEqual('PLEASE CHOOSE YOUR PAYMENT METHOD', title_payment)
        self.assertEqual('$19.25', price_finally)

    ''' Método con las post-condiciones'''

    def tearDown(self):
        self.driver.close()
        self.driver.quit()
Exemple #20
0
 def step_impl(self, text='Sign up'):
     text_link = PageIndex.get_text_of_link_sing_up(self)
     assert_equal(text_link,text)
Exemple #21
0
 def step_impl(self,item ='Laptops'):
     PageIndex.click_link_categorie(self,item)