Beispiel #1
0
 def choose_subject_heading(self, browser):
     LIB.wait_for_element(self, browser , self.subject_heading)
     select_text = LIB.get_data(self , key = "subject_heading")
     element = self.browser.find_element(*self.subject_heading)
     element.click()
     select = Select(element)
     select.select_by_visible_text(select_text)
Beispiel #2
0
def test_2():

        try:  
            # create lib page object  
            obj_lib=LIB()

            # open browser
            browser=obj_lib.open_browser()

            # navigate to the url
            obj_lib.page_load(browser)

            # create Home and Contact_us pages objects
            obj_home=Home(browser)
            obj_contact_us=Contact_us(browser)

            # click on Sign In button of the Home page
            browser.find_element(*obj_home.contact_us).click()

            # wait for the element to be visible in Sign in page
            obj_lib.wait_for_element(browser, obj_contact_us.subject_heading)

            # locate subject heading element and choose one of the options
            element = browser.find_element(*obj_contact_us.subject_heading)
            element.click()
            select_text = obj_lib.get_data(key='subject_heading')
            select_option = Select(element)
            select_option.select_by_visible_text(select_text)

            # fill in the email field
            valid_email_value=obj_lib.get_data(key='valid_email')
            browser.find_element(*obj_contact_us.email_address).send_keys(valid_email_value)

            # input in order reference field
            order_reference_value=obj_lib.get_data(key='references')
            browser.find_element(*obj_contact_us.order_reference).send_keys(order_reference_value)

            # fill in the message field
            message_text = obj_lib.get_data(key='contact_us_input_message')   
            browser.find_element(*obj_contact_us.message_field).send_keys(message_text) 
          
            # click Send button
            browser.find_element(*obj_contact_us.send_button).click()

            # validate that success message has appeared
            success_message=obj_lib.get_data(key='contact_us_success_message')
            assert success_message in browser.page_source
            print("Test 2 passes!")

        except Exception as e:
            # save the screenshot of the test file which has failed
            obj_lib.save_screenshot(browser)
            pytest.fail(e)
            print('Test 2 failed!')
            
        finally:
            # close the browser
            obj_lib.close_browser(browser)        
Beispiel #3
0
def test_1():
    try:
        #create lib page object
        obj_lib = LIB()

        # open browser
        browser = obj_lib.open_browser()

        # navigate to the url
        obj_lib.page_load(browser)

        # create Sign_in_page object
        obj_sign_in = Sign_in(browser)

        # parse data from config.json for email and password fields
        with open('config.json') as f:
            data = json.load(f)
        email_address = data['email']
        password = data['password']

        # create Home_page object
        obj_home = Home(browser)

        # click on Sign In button of the Home page
        browser.find_element(*obj_home.sign_in).click()

        # wait for the element to be visible in Sign in page
        obj_lib.wait_for_element(browser, obj_sign_in.email_address)

        # submit the email address and password parsed from config.json to be signed with
        browser.find_element(
            *obj_sign_in.email_address).send_keys(email_address)
        browser.find_element(*obj_sign_in.password).send_keys(password)

        # click the sign in button
        browser.find_element(*obj_sign_in.sign_in_button).click()

        # check that signed in to my account has been succesfull
        try:
            sign_out_title = browser.find_element(*obj_sign_in.sign_out).title
            print(sign_out_title)
        except:
            print(
                "The web element Sign out is not fount, so you arer signed in!"
            )

        print('Test 1 passed!')

    except Exception as e:
        # save the screenshot of the test file which has failed
        obj_lib.save_screenshot(browser)
        pytest.fail(e)
        print('Test 1 failed!')

    finally:
        # close the browser
        obj_lib.close_browser(browser)
Beispiel #4
0
def test_4():

    try:
        # open browser
        obj_lib = LIB()
        browser = obj_lib.browser()

        # navigate to url
        obj_lib.page_load(browser)

        # wait for woman tab and click
        obj_home = Home()
        obj_lib.wait_for_element(browser, obj_home.women)
        browser.find_element(*obj_home.women).click()

        """ I didn't fully understand part of locating list of elements yet, so I decided 
        don't just copy your code, I will view the lesson one more time, 
        and maybe will add this part"""

        #Nel, ok very, good just find locator which return you list f product names and product prices
def test_1():
    try:
        
        # get emai and password from config file
        with open ("config.json") as f:
            data = json.load(f)
        email_address = data["email"]
        password      = data["password"]

        # open the browser
        obj_lib = LIB()
        browser = obj_lib.open_browser()

        # navigate to url
        browser.page_load(browser)

        # create object of Sign_in class
        obj_sign_in = Sign_in(browser)

        # create object of Home class
        browser.find_element(*obj_home.sign_in).click()

        # waiting for email field, and filling email and password
        obj_lib.wait_for_element(browser, obj_sign_in.email_address)
        browser.find_element(*obj_sign_in.email_address).send_keys(email_address)
        browser.find_element(*obj_sign_in.password).send_keys(password)

        # click to sign_in button
        browser.find_element(*obj_sign_in.sign_in_btn).click()

        # check that we are in the correct page
        browser.find_element(*obj_sign_in.my_account_title)

    except:
        obj_lib.save_screenshot(browser)
        print ("test failed")
        
    finally:
        obj_lib.close_browser(browser)
def test_sign_in():
    try:
        #open browser
        open_page = LIB()
        browser = open_page.open_browser()

        #open url
        open_page.page_load(browser)

        sign_in = Log_In(browser)

        # click on Sign In button in header
        browser.find_element_by_css_selector(sign_in.sign_In_header).click()

        #wait for email field visibility
        open_page.wait_for_element(browser, sign_in.sign_In)

        # enter email address
        sign_in.enter_email()

        # enter password
        sign_in.enter_password()

        #click Sign In button
        sign_in.click_sign_in()

        #verify Sign in
        home_page = Home_Page(browser)

        registered_name = home_page.get_account_Sign_In_Name()
        config_registered_name = open_page.config_data['registered_name']
        assert registered_name == config_registered_name, open_page.save_screenshot(
            browser)

    finally:
        #close browser
        open_page.close_browser(browser)
def test_4():

    try:
        # create lib page object
        obj_lib = LIB()

        # open browser
        browser = obj_lib.open_browser()

        # navigate to the url
        obj_lib.page_load(browser)

        # wait for the Women tab to be visible in Home page, locate it and click on it
        obj_home = Home(browser)
        obj_lib.wait_for_element(browser, obj_home.women)
        browser.find_element(*obj_home.women).click()

        # wait for the product names and prices in Women tab to be visible in Home page
        obj_lib.wait_for_elements(browser, obj_home.product_names)
        obj_lib.wait_for_elements(browser, obj_home.product_prices)

        # return dictionary with Women tab's products names and prices
        products_names_prices = obj_home.find_products_name_price(browser)

        # write the products names and prices in log.txt file
        obj_lib.write_to_file(products_names_prices)

    except Exception as e:
        # save the screenshot of the test file which has failed
        obj_lib.save_screenshot(browser)
        pytest.fail(e)
        print('Test 4 failed!')

    finally:
        # close the browser
        obj_lib.close_browser(browser)
 def select_subject_heading(self, browser):
     LIB.wait_for_element(self, browser, self.subject_heading_locator)
     select_text = LIB.get_data(self, key='subject_heading')
     select = Select(
         self.browser.find_element_by_xpath(self.subject_heading))
     select.select_by_visible_text(select_text)