def test_2():
    try:
        #open browser
        obj_lib = LIB()
        browser = obj_lib.open_browser()

        # navigate to url
        obj_lib.page_load(browser)

        #create contuct_us object
        obj_contuct_us = Contact_Us(browser)
        obj_home = Home(browser)

        #steps
        obj_home.click_contuct_us(browser)
        obj_contuct_us.choose_subject_heading(browser)
        obj_contuct_us.input_email_address()
        obj_contuct_us.input_order_referenc()
        obj_contuct_us.click_send_button()

        #Verify that validation message displayes
        success_message = obj_lib.get_data('contact_us_error_message')
        assert success_message in browser.page_source
        print('Test run pass!')

    except:
        obj_lib.save_screenshot(browser)
        print('Test run failed!')

    finally:
        #Close browser
        obj_lib.close_browser(browser)
예제 #2
0
 def give_product_name_price(self, browser):
     produc_name_list = []
     produc_price_list = []
     LIB.wait_for_elements(self, browser, self.product_name)
     produc_name = self.browser.find_elements(*self.product_name)
     for i in produc_name:
         produc_name_list.append(i.text)
     produc_price = self.browser.find_elements(*self.product_price)
     for i in produc_price:
         produc_price_list.append(i.text)
     del produc_price_list[
         1::2]  #Delete every second element (counting from the firts)
     return dict(zip(produc_name_list, produc_price_list))
예제 #3
0
def test_1():
    try:
        #open browser
        obj_lib = LIB()
        browser = obj_lib.open_browser()

        #create  objects
        obj_cotact = CONTACT_US(browser)
        obj_home = Home(browser)

        #steps
        obj_lib.page_load(browser)
        obj_lib.wait_for_element(browser, obj_home.contact_us).click()
        obj_cotact.fill_without_name(browser)
        error = browser.find_element(*obj_cotact.fields_error)
        assert error.text == obj_lib.get_data("error_messagge")
        error_1 = browser.find_element(*obj_cotact.field_error_out)
        assert error_1.text == obj_lib.get_data("error_messagge_out")

    except Exception as exp:
        obj_lib.write_to_file(f"In case 11,  error reason is -{exp}")
        obj_lib.save_screenshot(browser, "Case_11")
        raise exp

    finally:
        #Close browser
        obj_lib.close_browser(browser)
예제 #4
0
def test_2():
    try:
        #Create driver
        obj = LIB()
        browser = obj.open_browser()

        #Get web page
        obj.page_load(browser)

        #Create Home page object
        obj_home = Home(browser)

        #Find contact us element and click
        browser.find_element(*obj_home.contact_us).click()

        #Create Contact_us obj
        obj_contact_us = Contact_Us(browser)

        #Wait for visible nessasery element
        obj.wait_for_element(browser, obj_contact_us.subject_heading)

        #Fill in nessesary formation in input fields
        select = Select(browser.find_element(*obj_contact_us.subject_heading))
        select.select_by_visible_text(obj.get_data('subject_heading'))
        browser.find_element(*obj_contact_us.email).send_keys(
            obj.get_data('valid_email'))
        browser.find_element(*obj_contact_us.message).send_keys(
            obj.get_data('contact_us_input_message'))

        #Click send button
        browser.find_element(*obj_contact_us.submit_message).click()

        #Compare get information and information in page
        success_message = obj.get_data('contact_us_success_message')
        assert success_message in browser.page_source
        print('Test is pass!')

    except Exception as e:
        print(e)
        obj.save_screenshot(browser)
        print('Test is fail!')
        raise

    finally:
        obj.close_browser(browser)


#Nel, very good, need to keep negative test case as well
def test_1():
    try:
        #open browser
        obj_lib = LIB()
        browser = obj_lib.open_browser()

        # navigate to url
        obj_lib.page_load(browser)

        #create  objects
        obj_our = OUR_COURSES(browser)
        obj_home = Home(browser)

        #steps
        browser.find_element(*obj_home.our_courses).click()
        assert obj_our.check_trainings_href(browser) == obj_lib.get_data(
            "href_list")

    except Exception as exp:
        obj_lib.write_to_file(f"In case 2,  error reason is -{exp}")
        obj_lib.save_screenshot(browser, "Case_2")
        raise exp

    finally:
        #Close browser
        obj_lib.close_browser(browser)
def test_1():
    try:
        #open browser
        obj_lib = LIB()
        browser = obj_lib.open_browser()

        #create  objects
        obj_our = OUR_COURSES(browser)
        obj_home = Home(browser)

        #steps
        obj_lib.page_load(browser)
        obj_lib.wait_for_element(browser, obj_home.our_courses).click()
        assert obj_our.check_trainings_data_name(browser) == obj_lib.get_data(
            "tr_names")

    except Exception as exp:
        obj_lib.write_to_file(f"In case 1,  error reason is -{exp}")
        obj_lib.save_screenshot(browser, "Case_1")
        raise exp

    finally:
        #Close browser
        obj_lib.close_browser(browser)
예제 #7
0
def test_3():
    try:
        #Create drivere and open browser
        obj = LIB()
        browser = obj.open_browser()

        #load automationpractice.com page
        obj.page_load(browser)

        #Create Home object
        obj_home = Home(browser)

        #Wait to some element visible on page
        obj.wait_for_element(browser, obj_home.menu_women)

        #Find intrerested element on menu and click it
        browser.find_element(*obj_home.menu_women).click()

        #Wait to product element visible on page
        obj.wait_for_elements(browser, obj_home.product_name)

        #Get some information about product name and product price
        product_name_ls = []
        product_price_ls = []
        product_name = browser.find_elements(*obj_home.product_name)
        for i in product_name:
            product_name_ls.append(i.text)
        product_price = browser.find_elements(*obj_home.product_price)
        for i in product_price:
            product_price_ls.append(i.text)
        my_dict = dict(zip(product_name_ls, product_price_ls))
        obj.write_to_file(my_dict)
        print("Test is pass!")

    except Exception as e:
        print(e)
        obj.save_screenshot(browser)
        print("Test is fail!")
        raise
    finally:
        obj.close_browser(browser)


#Nel, good, part with product would be better to keep as function in POM, as you can use this in future
예제 #8
0
 def click_contuct_us(self, browser):
     LIB.wait_for_element(self, browser, self.contact_us)
     self.browser.find_element(*self.contact_us).click()
def test_1():
    try:

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

        #create  objects
        obj_train = OUR_TRAINERS(browser)
        obj_home = Home(browser)

        #steps
        obj_lib.page_load(browser)
        obj_lib.wait_for_element(browser, obj_home.our_trainers).click()
        time.sleep(10) # Here I have a problem with my internet, for it here i use time sleep
        obj_lib.wait_for_element(browser, obj_train.trainer_Nelli).click()
        assert  browser.title == obj_lib.get_data("Nelli's_page_titile")
        assert  browser.current_url == obj_lib.get_data( "Nelli's_page_url")
        assert  obj_lib.get_data("Nelli's_page_info_1") in browser.page_source
        assert  obj_lib.get_data("Nelli's_page_info_2") in browser.page_source
        assert  obj_lib.get_data("Nelli's_page_info_3") in browser.page_source
        assert  obj_lib.get_data("Nelli's_page_info_4") in browser.page_source


    except Exception as exp:
        obj_lib.write_to_file(f"In case 4,  error reason is -{exp}")
        obj_lib.save_screenshot(browser, "Case_4")
        raise exp



    finally:
        # Close browser
        obj_lib.close_browser(browser)
def test_1():
    try:
        #open browser
        obj_lib = LIB()
        browser = obj_lib.open_browser()

        #create  objects
        obj_home = Home(browser)

        #steps
        obj_lib.page_load(browser)
        obj_lib.wait_for_element(browser, obj_home.blog).click()
        assert browser.title == obj_lib.get_data("blog_title")
        assert browser.current_url == obj_lib.get_data("blog_url")
        assert obj_lib.get_data("blog_letter") in browser.page_source

    except Exception as exp:
        obj_lib.write_to_file(f"In case 6,  error reason is -{exp}")
        obj_lib.save_screenshot(browser, "Case_6")
        raise exp

    finally:
        # Close browser
        obj_lib.close_browser(browser)
def test_1():
    try:
        #open browser
        obj_lib = LIB()
        browser = obj_lib.open_browser()

        #create  objects
        obj_home = Home(browser)

        #steps
        obj_lib.page_load(browser)
        obj_lib.wait_for_element(browser, obj_home.contact_us).click()
        assert obj_lib.get_data("contact_us_address") in browser.page_source
        assert obj_lib.get_data("contact_us_phone") in browser.page_source
        assert obj_lib.get_data("contact_us_@mail") in browser.page_source

    except Exception as exp:
        obj_lib.write_to_file(f"In case 9,  error reason is -{exp}")
        obj_lib.save_screenshot(browser, "Case_9")
        raise exp

    finally:
        #Close browser
        obj_lib.close_browser(browser)
예제 #12
0
def test_4():
    try:

        # get email and pass from config
        with open('config.json') as f:
            data = json.load(f)
        email_address = data['eMail']
        password = data['password']

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

        # navigate to url
        obj_lib.page_load(browser)

        #Create Home page objcet
        obj_home = Home(browser)

        #click on Sign in
        browser.find_element(*obj_home.sign_in).click()

        #Create Sign In object
        obj_signin = Sign_in(browser)

        #submit with email and pass
        obj_lib.wait_for_element(browser, obj_signin.email_address)
        browser.find_element(
            *obj_signin.email_address).send_keys(email_address)
        browser.find_element(*obj_signin.password).send_keys(password)

        #click on Sign In button
        browser.find_element(*obj_signin.sign_in_btn).click()

        #Check that you are in My accout page
        browser.find_element(*obj_signin.my_account_title)

        print('Test run pass!')

    except Exception as e:
        print(e)
        obj_lib.save_screenshot(browser)
        print('Test run failed!')

    finally:
        #Close browser
        obj_lib.close_browser(browser)
예제 #13
0
def test_1():
    try:

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

        # navigate to url
        obj_lib.page_load(browser)

        #create  objects
        obj_home = Home(browser)

        #steps
        obj_lib.wait_for_element(browser, obj_home.our_courses).click()
        obj_lib.wait_for_element(browser, obj_home.programming).click()
        assert browser.current_url == obj_lib.get_data(
            "current_url_all_courses")
        assert browser.title == obj_lib.get_data("title_courses")

    except Exception as exp:
        obj_lib.write_to_file(f"In case 3,  error reason is -{exp}")
        obj_lib.save_screenshot(browser, "Case_3")
        raise exp

    finally:
        #Close browser
        obj_lib.close_browser(browser)
def test_1():
    try:
        #open browser
        obj_lib = LIB()
        browser = obj_lib.open_browser()

        #create  objects
        obj_about = ABOUT_US(browser)
        obj_home = Home(browser)

        #steps
        obj_lib.page_load(browser)
        obj_lib.wait_for_element(browser, obj_home.about_us).click()
        assert obj_about.return_text(browser, obj_about.text_info_1) == obj_lib.get_data("about_us_info_1")
        assert obj_about.return_text(browser, obj_about.text_info_2) == obj_lib.get_data("about_us_info_2")

    except Exception as exp:
        obj_lib.write_to_file(f"In case 7,  error reason is -{exp}")
        obj_lib.save_screenshot(browser, "Case_7")
        raise exp


    finally:
        #Close browser
        obj_lib.close_browser(browser)
예제 #15
0
def test_1():
    try:
        #Create drivere and open browser
        br = LIB()
        browser = br.open_browser()

        #load automationpractice.com page 
        br.page_load(browser)

        #Create Home object
        page_home = Home(browser)

        #Find some element and click
        browser.find_element(*page_home.sing_in).click()

        #Create Sign_in object
        page_sing_in = Sign_in(browser)

        #Get some data from config file
        with open('config.json') as f:
            data = json.load(f)
        email_add = data['eMail']
        password = data['password']  

        #Wait for element visible                  
        br.wait_for_element(browser, page_sing_in.email_address)

        #Fill in nessesary information
        browser.find_element(*page_sing_in.email_address).send_keys(email_add)
        browser.find_element(*page_sing_in.password).send_keys(password)

        #Click on send button
        browser.find_element(*page_sing_in.sign_in_btn).click()
        browser.find_element(*page_sing_in.my_account_title)
        print('Test is pass!')
        
    except Exception as e:
        print(e)
        br.save_screenshot(browser)
        print('Test is fail!')
    finally:
        br.close_browser(browser)


#--Nel, raise part use in except block