def test_3():
    try:
        #create objet of the LIB class . open browser and go to URL
        obj_lib = LIB()
        browser = obj_lib.open_browser()
        obj_lib.page_load(browser)

        # Creating homepage & contact us page objects
        obj_home = Home(browser)
        obj_contuct_us = Contuct_us(browser)

        # Filling all mandatory fields
        obj_contuct_us.choose_subject_heading(browser)
        obj_contuct_us.input_invalid_email()
        obj_contuct_us.input_reference()
        obj_contuct_us.click_send()

        #check error message
        error_message = obj_lib.get_data("contact_us_error_message")
        assert success_message in browser.page_source
        print("test passed")

    except:
        obj_lib.save_screenshot(browser)
        print("Test failed")

    finally:
        obj_lib.close_browser(browser)
예제 #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)        
예제 #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)
def test_contact_us():
    try:
        open_page = LIB()
        browser = open_page.open_browser()
        open_page.page_load(browser)
        subject_heading = open_page.test_data['subject_heading'][1]
        message = open_page.test_data['message']
        image = open_page.test_data['img_path']
        order_refferance = open_page.test_data['ord_refferance']
        email_address = open_page.config_data['email']

        send_message = Contact_Us(browser)

        #select subject heading
        send_message.select_subject_heading('subject_heading')

        #write email address
        send_message.email_address()

        # write order refferance
        send_message.order_refference()

        #attach file
        send_message.attach_file()

        #write message
        send_message.write_message()

        #send message
        send_message.send_message()

        #validation

        success_message = 'successfully sent'
        validation = send_message.check_success(success_message)

        assert success_message in validation, open_page.save_screenshot(
            browser)

    finally:
        #close browser
        open_page.close_browser(browser)
예제 #5
0
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_contact_us():
    try:
        open_page = LIB()
        browser = open_page.open_browser()
        open_page.page_load(browser)
        send_message = Contact_Us(browser)

        #click on Contact US
        browser.find_element_by_css_selector(
            send_message.header_contact_us).click()

        #select subject heading
        send_message.select_subject_heading(browser)

        #write email address
        send_message.email_address()

        # write order refferance
        send_message.order_refference()

        #attach file
        send_message.attach_file()

        #write message
        send_message.write_message()

        #send message
        send_message.send_message()

        #validation
        success_message = 'successfully sent'
        validation = send_message.check_success(success_message)

        assert success_message in validation, open_page.save_screenshot(
            browser)

    finally:
        #close browser
        open_page.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)