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_SignIn():
    try:
        ## Step 1) Open Chrome browser
        object_lib = LIB()
        browser = object_lib.OpenBrowser()

        ## 2) Go to URL
        object_lib.PageLoad(browser)

        ## 3) Click to Sign In in Home page

        object_home = Home(browser)
        object_home.OpenSignIn(browser)

        ## 4) Fill email address and password
        object_signin = Sign_In(browser)
        object_signin.LoginPass(browser)

        ## 5)Click Sign In sign_in_button
        object_signin.ClickSignIn(browser)

        ## 6) Verify that you signed successfully
        assert "My account" in browser.title

        print("Test run Passed!")

    # except Exception as e:
    #     print(e)
    #     print("Test run Failed")

    finally:
        object_lib.CloseBrowser(browser)
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)
def test_ContuctUs_pass():
    try:
## 1. Go to URL
        object_lib = LIB()
        browser = object_lib.OpenBrowser()
        object_lib.PageLoad(browser)

# 2. Click to Contact US sign_in_button
        object_home = Home(browser)
        contact_us_page = object_home.ContactUs(browser)

##browser.find_element(By.CSS_SELECTOR, "div#contact-link a").send_keys(Keys.ENTER)

# 3. Fill all fields in Contact Us and click on Send button
        object_contactus = Contact_Us(browser)
        object_contactus.FillFeilds(browser)

        object_contactus.FillText(browser)

        object_contactus.ClickSend(browser)

# 4. Validate that success message displayed
        assert "Your message has been successfully sent to our team." in browser.page_source
# 5. Close browser

        print("Test run Passed!")
        
    # except Exception as e:
    #     print(e)
    #     print("Test run Failed")

    finally:
        object_lib.CloseBrowser(browser)
Beispiel #5
0
    def find_products_name_price(self, browser):
        product_names_list = []
        product_prices_list = []
        # wait for the product names elements to be visible in the UI
        LIB.wait_for_elements(self, browser, self.product_names)
        # locate the product names elements
        product_names = self.browser.find_elements(*self.product_names)
        # iterate in product names and append the elements' texts to the list
        for i in product_names:
            product_names_list.append(i.text)

        # locate the product prices elements
        product_prices = self.browser.find_elements(*self.product_prices)
        # iterate in product prices and append the elements' texts to the list
        for i in product_prices:
            product_prices_list.append(i.text)
        # delete every second element counting from the first one
        #del product_prices_list[1::2]
        # create dictionary from the 2 lists and return it
        return dict(zip(product_names_list, product_prices_list))
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_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)
        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)
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)
Beispiel #10
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
Beispiel #11
0
 def input_email_address(self):
     email = LIB.get_data(self, key = "valid_email")
     self.browser.find_element(*self.email_address).send_keys(email)
Beispiel #12
0
 def input_reference(self):
     ref = LIB.get_data(self, key = "references")
     self.browser.find_element(*self.order_reference).send_keys(ref)
Beispiel #13
0
 def input_message(self):
     mes = LIB.get_data(self, key = "contact_us_input_message")
     self.browser.find_element(*self.message_field).send_keys(mes)
Beispiel #14
0
 def ClickSend(self, browser):
     LIB.MoveToElement(self, browser, self.contact_us_button)
     element = self.browser.find_element(*self.contact_us_button)
     browser.find_element(By.ID, "submitMessage").send_keys(Keys.ENTER)
def test_3():

    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)

        # click Send button
        browser.find_element(*obj_contact_us.send_button).click()

        # validate that error message has appeared
        error_message = obj_lib.get_data(key='contact_us_error_message')
        assert error_message in browser.page_source
        print("Test 3 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 3 failed!')

    finally:
        # close the browser
        obj_lib.close_browser(browser)
 def enter_password(self):
     password = LIB.get_config_data(self, key='password')
     self.browser.find_element_by_id(self.password).send_keys(password)
 def enter_email(self):
     email = LIB.get_config_data(self, key='email')
     self.browser.find_element_by_id(self.email).send_keys(email)
Beispiel #18
0
 def ClickSignIn(self, browser):
     LIB.MoveToElement(self, browser, self.sign_in_button)
     element = self.browser.find_element(*self.sign_in_button)
     browser.find_element(By.ID, "SubmitLogin").send_keys(Keys.ENTER)
Beispiel #19
0
 def input_invalid_email(self):
     inv_email = LIB.get_data(self , key = "invalid_email")
     self.browser.find_element(*self.email_address).send_keys(inv_email)
 def write_message(self):
     message = LIB.get_data(self, key='message')
     self.browser.find_element_by_id(self.message).send_keys(message)
 def attach_file(self):
     img = LIB.get_data(self, key='img_path')
     self.browser.find_element_by_id('fileUpload').send_keys(img)
 def order_refference(self):
     order_ref = LIB.get_data(self, key='ord_refferance')
     self.browser.find_element_by_id(
         self.order_refference_locator).send_keys(order_ref)
 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)
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)
Beispiel #25
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)