def test_10_check_font_of_answer_options(self): sleep(3) for i in driver.find_elements_by_css_selector('output > div'): log.info(i.value_of_css_property('font-size')) log.info(i.value_of_css_property('font-family'))
def select_radio_button(self, i): ActionChains(driver).move_to_element( self.radio_button_inner(i)).click().perform() # self.radio_button_inner(i).click() log.info('radio button {} is selected'.format(i)) log.info('it is located at {}'.format(self.radio_button(i).location))
def check_checkbox_selection_color(self, i): sleep(1) bg_color_after_selection = self.checkbox(i).value_of_css_property( 'background-color') log.info('background color after selecting checkbox: {}'.format( bg_color_after_selection)) return bg_color_after_selection
def select_continue_test_email_data(self): continue_button = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(3)'))) enability_of_continue = continue_button.is_enabled() self.assertIs(enability_of_continue, True) if (enability_of_continue == True): continue_button.click() else: log.info('Continue button is disable') if (driver.find_elements_by_css_selector( 'body > div:nth-child(6) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body > form > div > div.ant-form-item-control-wrapper > div > input' )): email_field = WebDriverWait(driver, 5).until( EC.presence_of_element_located(( By.CSS_SELECTOR, 'body > div:nth-child(6) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body > form > div > div.ant-form-item-control-wrapper > div > input' ))) with open( '/home/alqama/workspace/autotest-englishduniya/webform/email_test_data.csv', newline='') as csvfile: spamreader = csv.reader(csvfile, delimiter='\t') for row in spamreader: email_field.clear() email_field.send_keys(row[0]) email_send = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, '.ant-modal-body > button'))) enability_of_email_send = email_send.is_enabled() try: self.assertEqual(row[1], str(enability_of_email_send)) except AssertionError as e: print('{} should be {} but it is {}'.format( row[0], row[1], str(enability_of_email_send))) email_close = WebDriverWait(driver, 4).until( EC.presence_of_element_located( (By.CLASS_NAME, 'ant-modal-close'))) email_close.click() else: print('email Pop up not present')
def test_05_check_radio_button_selection_after_clicking_twice(self): for j in range(1, len(self.radio_buttons_inner_list()) + 1): ActionChains(driver).double_click(self.radio_button(j)).perform() log.info('Clicked twice on radio button {}'.format(j)) self.assertEqual(self.check_radio_button_selection(j), True) self.check_continue_button_enabled()
def check_back_button_presence(self): back_button = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(2)'))) log.info('Back button present : {}'.format(back_button.is_displayed())) return back_button.is_displayed()
def check_radio_selection_color(self, i): sleep(1) self.radio_button(i) bg_color_after_selection = self.radio_button(i).value_of_css_property( 'background-color') log.info('background color after selecting radio: {}'.format( bg_color_after_selection)) return bg_color_after_selection
def test_05_check_checkbox_selection_after_clicking_twice(self): for j in range(1, len(self.checkbox_inner_list()) + 1): self.select_checkbox(j) self.select_checkbox(j) log.info('Clicked twice on chackbox {}'.format(j)) self.assertEqual(self.check_checkbox_selection(j), False) self.check_continue_button_enabled()
def select_continue_button(self): continue_button = WebDriverWait(driver, 10).until( EC.visibility_of_element_located( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(3)'))) enability_of_continue = continue_button.is_enabled() self.assertIs(enability_of_continue, True) if (enability_of_continue == True): continue_button.click() else: log.info('Continue button is disable')
def check_continue_button_enabled(self): continue_button = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(3)'))) if ((self.check_continue_button_presence()) == True): log.info('Continue button is enabled : {}'.format( continue_button.is_enabled())) return continue_button.is_enabled() else: log.info('continue button is not present')
def check_checkbox_hover(self, i): bg_color_before_hovering = self.checkbox(i).value_of_css_property( 'background-color') log.info('background color before hovering on element : {}'.format( bg_color_before_hovering)) self.assertEqual(bg_color_before_hovering, self.element_default_color) ActionChains(driver).move_to_element(self.checkbox(i)).perform() sleep(1) bg_color_after_hovering = self.checkbox(i).value_of_css_property( 'background-color') log.info('background color after hovering on element : {}'.format( bg_color_after_hovering)) self.assertEqual(bg_color_after_hovering, self.element_hover_color)
def select_back_button(self): back_button = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(2)'))) enability_of_back = back_button.is_enabled() self.assertIs(enability_of_back, True) if (enability_of_back == True): back_button.click() else: log.info('Back button is disable')
def check_radio_button_hover(self, i): self.radio_button(i) bg_color_before_hovering = self.radio_button(i).value_of_css_property( 'background-color') log.info('background color before hovering on element : {}'.format( bg_color_before_hovering)) self.assertEqual(bg_color_before_hovering, 'rgba(0, 0, 0, 0)') ActionChains(driver).move_to_element(self.radio_button(i)).perform() sleep(1) bg_color_after_hovering = self.radio_button(i).value_of_css_property( 'background-color') log.info('background color after hovering on element : {}'.format( bg_color_after_hovering)) self.assertEqual(bg_color_after_hovering, 'rgba(217, 217, 217, 0.3)')
def check_continue_button_presence(self): try: continue_button = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(3)'))) log.info('Continue button present : {}'.format( continue_button.is_displayed())) # print ('Continue button is present : {}'.format(continue_button.is_displayed())) return continue_button.is_displayed() except TimeoutException as e: log.info('continue button not present')
def check_hover_on_continue_button(self): if ((self.check_continue_button_enabled()) == True): continue_button = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(3)'))) bg_color_before_hovering = continue_button.value_of_css_property( 'background-color') log.info('background color before hovering on element : {}'.format( bg_color_before_hovering)) self.assertEqual(bg_color_before_hovering, self.enable_continue_before_hover) ActionChains(driver).move_to_element(continue_button).perform() sleep(1) bg_color_after_hovering = continue_button.value_of_css_property( 'background-color') log.info('background color after hovering on element : {}'.format( bg_color_after_hovering)) self.assertEqual(bg_color_after_hovering, self.enable_continue_after_hover) else: continue_button = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(3)'))) bg_color_before_hovering = continue_button.value_of_css_property( 'background-color') log.info('background color before hovering on element : {}'.format( bg_color_before_hovering)) self.assertEqual(bg_color_before_hovering, self.disable_continue_before_hover) ActionChains(driver).move_to_element(continue_button).perform() sleep(1) bg_color_after_hovering = continue_button.value_of_css_property( 'background-color') log.info('background color after hovering on element : {}'.format( bg_color_after_hovering)) self.assertEqual(bg_color_after_hovering, self.disable_continue_after_hover)
def select_continue_button_check_popup(self): continue_button = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(3)'))) enability_of_continue = continue_button.is_enabled() self.assertIs(enability_of_continue, True) if (enability_of_continue == True): continue_button.click() try: email_close = WebDriverWait(driver, 4).until( EC.presence_of_element_located( (By.CLASS_NAME, 'ant-modal-close'))) email_close.click() except TimeoutException as ex: log.info('no email pop up') else: log.info('Continue button is disable')
def test_09_check_answer_selection_retains_on_Continue(self): for j in range(1, len(self.checkbox_list()) + 1): self.select_checkbox(j) self.select_continue_button() if (driver.find_elements_by_class_name('ant-modal-footer')): try: email_back = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, '.ant-modal-footer > button:nth-child(1)'))) sleep(1) email_back.click() except TimeoutException as ex: log.info('no email pop up') else: self.select_back_button() self.assertEqual(self.check_checkbox_selection(j), True)
def select_continue_enter_email_if_present(self): continue_button = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, '.section-carousel-btn-container > button:nth-child(3)'))) enability_of_continue = continue_button.is_enabled() print(continue_button.is_enabled()) print('continue enable = {}'.format( self.assertTrue(enability_of_continue))) if (enability_of_continue == True): continue_button.click() else: log.info('Continue button is disable') if (driver.find_elements_by_css_selector( 'body > div:nth-child(6) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body > form > div > div.ant-form-item-control-wrapper > div > input' )): try: email_field = WebDriverWait(driver, 5).until( EC.presence_of_element_located(( By.CSS_SELECTOR, 'body > div:nth-child(6) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body > form > div > div.ant-form-item-control-wrapper > div > input' ))) email_field.send_keys("*****@*****.**") email_send = WebDriverWait(driver, 10).until( EC.element_to_be_clickable(( By.CSS_SELECTOR, '.ant-modal-body > button.ant-btn result-modal-btn ant-btn-secondary' ))) email_send.click() except TimeoutException as ex: log.info('no email pop up') else: log.info('Pop up not present')
def select_checkbox(self, i): ActionChains(driver).move_to_element(self.checkbox_inner(i)).perform() # log.info('it is located at {}'.format(self.checkbox_inner(i)).location()) self.checkbox_inner(i).click() log.info('checkbox {} is selected'.format(i))