How to use selenium_select method in toolium

Best Python code snippet using toolium_python

create_course_page.py

Source:create_course_page.py Github

copy

Full Screen

1from selenium.common.exceptions import NoSuchElementException, TimeoutException2from selenium.webdriver.common.by import By3from selenium.webdriver.support import expected_conditions as EC4from selenium.webdriver.support.select import Select5from selenium.webdriver.support.ui import WebDriverWait6from selenium_tests.canvas_site_creator.page_objects.base_page_object \7 import BulkCreateBasePageObject8class Locators(object):9 CODE_TYPE_DROPDOWN = (By.ID, "course-code-type")10 COURSE_CODE = (By.ID, "course-code")11 COURSE_TITLE = (By.ID, "course-title")12 CREATE_NEW_COURSE_BUTTON = (By.ID, "create-course-instance")13 MODAL_CONFIRM_BUTTON = (By.ID, "existing-course-modal-confirm")14 SHORT_TITLE = (By.ID, "course-short-title")15 SUCCESS_MSG = (By.ID, "success-msg")16 TERM_CODE = (By.ID, "course-term")17 # lots of problems with CSS locators in selenium webdriver; this one18 # works as currently there should only be one row in table, and one link19 # in that row20 SITE_FIELD = (By.CSS_SELECTOR, "#new-course-info-container tbody a")21class CreateCoursePageObject(BulkCreateBasePageObject):22 page_loaded_locator = Locators.TERM_CODE23 def add_new_course_instance(self,24 course_code,25 course_title,26 course_short_title,27 term):28 """29 This function will fill the form and button click to create the30 course31 """32 self.get_course_code(course_code)33 self.get_course_title(course_title)34 self.get_short_title(course_short_title)35 self.get_term(term)36 add_course_link = self.find_element(*Locators.CREATE_NEW_COURSE_BUTTON)37 if add_course_link.is_enabled():38 add_course_link.click()39 def get_term(self, term_code):40 """41 Select the term from the dropdown42 """43 # adding an explicit wait as there is some flakiness in one of the tests44 # sporadically failing when the terms have not loaded on page.45 WebDriverWait(self._driver, 30).until(46 EC.visibility_of_element_located(Locators.TERM_CODE))47 element_select = self.find_element(*Locators.TERM_CODE)48 selenium_select = Select(element_select)49 selenium_select.select_by_visible_text(term_code)50 return selenium_select51 def get_course_title(self, course_title):52 """53 Fill in the course title54 """55 element = self.find_element(*Locators.COURSE_TITLE)56 element.clear()57 element.send_keys(course_title)58 return element59 def get_short_title(self, course_short_title):60 """61 Fill in the short tile62 """63 element = self.find_element(*Locators.SHORT_TITLE)64 element.clear()65 element.send_keys(course_short_title)66 return element67 def get_course_code(self, course_code):68 """69 Select ILE from the dropdown and70 fill in the course code (registrar code) in the textbox71 """72 element_select = self.find_element(*Locators.CODE_TYPE_DROPDOWN)73 selenium_select = Select(element_select)74 selenium_select.select_by_value("ILE")75 element = self.find_element(*Locators.COURSE_CODE)76 element.clear()77 element.send_keys(course_code)78 return element79 def success_message_visible(self):80 """81 Wait for the success message to be visible before time-out82 """83 try:84 WebDriverWait(self._driver, 60).until(85 EC.visibility_of_element_located(Locators.SUCCESS_MSG)86 )87 except TimeoutException:88 return False89 return True90 def confirm_modal_visible(self):91 """92 Look for the modal window, if previous course instance for the93 school, term and course code has already been created94 Note of possible failure:95 Modal window might fail to display within time limit,96 (currently set to 10s), possibly due to slowness with connecting97 with the back-end or the processing of the number of rows found on db.98 """99 try:100 self.find_element(*Locators.MODAL_CONFIRM_BUTTON)101 except NoSuchElementException:102 return False103 return True104 def click_confirmation_modal(self):105 """106 Click OK in the modal window107 """108 element = self.find_element(*Locators.MODAL_CONFIRM_BUTTON)109 element.click()110 def go_to_new_canvas_course(self):111 """Click on the canvas link which opens up in a new window. Switch to112 new window and parent frame113 """114 canvas_site_element = self.find_element(*Locators.SITE_FIELD)115 canvas_site_element.click()116 # switch to active window117 active_window = self._driver.window_handles[-1]118 self._driver.switch_to_window(active_window)119 # switch to parent frame...

Full Screen

Full Screen

select_page_element.py

Source:select_page_element.py Github

copy

Full Screen

...8 @option.setter9 def option(self, value):10 self.selenium_select.select_by_visible_text(value)11 @property12 def selenium_select(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run toolium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful