Best Python code snippet using toolium_python
main.py
Source:main.py
...1415def debug_log(text):16 print('DEBUG: ' + text)1718def wait_until_clickable(button, find, custom_wait=load_wait_time):19 return WebDriverWait(driver, custom_wait).until(EC.element_to_be_clickable((find, button)))2021driver = Firefox(options=opts)22driver.get('https://uclasurveys.co1.qualtrics.com/jfe/form/SV_3qRLtouCYKzBbH7')23wait_until_clickable("//*[@id='QID3-2-label']", By.XPATH).click()24wait_until_clickable("//*[@id='NextButton']", By.XPATH).click()2526debug_log("enter credentials")27wait_until_clickable('logon', By.ID).send_keys('cheungbrenden')28wait_until_clickable('pass', By.ID).send_keys('D2IbT2Di()')29wait_until_clickable('primary-button', By.CLASS_NAME).click()3031debug_log("click send push")32driver.switch_to.frame(driver.find_element_by_tag_name('iframe'))33send_push_xpath = '/html/body/div/div/div[1]/div/form/div[1]/fieldset/div[1]/button'34wait_until_clickable(send_push_xpath, By.XPATH).click()35driver.switch_to.default_content()363738wait_until_clickable('//*[@id="NextButton"]', By.XPATH).click()39sleep(1)40wait_until_clickable('//*[@id="NextButton"]', By.XPATH).click()41wait_until_clickable('//*[@id="QID221-15-label"]', By.XPATH).click()42wait_until_clickable('//*[@id="NextButton"]', By.XPATH).click()43sleep(1)44wait_until_clickable('//*[@id="NextButton"]', By.XPATH).click()45sleep(1)46wait_until_clickable('//*[@id="NextButton"]', By.XPATH).click()47sleep(1)48wait_until_clickable('//*[@id="NextButton"]', By.XPATH).click()49wait_until_clickable('//*[@id="QID2-1-label"]', By.XPATH).click()50wait_until_clickable('//*[@id="NextButton"]', By.XPATH).click()51wait_until_clickable('//*[@id="QID3-2-label"]', By.XPATH).click()52wait_until_clickable('//*[@id="NextButton"]', By.XPATH).click()53wait_until_clickable('//*[@id="QID12-2-label"]', By.XPATH).click()
...
form_page.py
Source:form_page.py
...18 COMMANDS_LIST = (By.NAME, "selenium_commands")19 BUTTON = (By.NAME, "submit")20 def input_first_name(self):21 name = ''.join(random.choices(string.ascii_lowercase, k=5))22 self.wait_until_clickable(self.NAME_FIELD).send_keys(name)23 def input_last_name(self):24 last_name = ''.join(random.choices(string.ascii_lowercase, k=5))25 self.wait_until_clickable(self.SURNAME_FIELD).send_keys(last_name)26 def female_sex_click(self):27 self.wait_until_clickable(self.FEMALE_SEX_RADIO).click()28 def experience_click(self, number: int):29 self.wait_until_clickable((By.CSS_SELECTOR, self.EXPERIENCE_RADIO.format(number))).click()30 def automation_click(self):31 self.wait_until_clickable(self.AUTOMATION_TESTER_FIELD).click()32 def input_date(self):33 self.wait_until_clickable(self.DATE_FIELD).send_keys(datetime.now().strftime("%m/%d/%Y"))34 def upload_file(self):35 self.wait_until_clickable(self.UPLOAD_FILE).send_keys(os.path.join(os.getcwd(), "Koala.jpeg"))36 def selenium_click(self):37 self.wait_until_clickable(self.SELENIUM_CHECKBOX).click()38 def select_europe(self):39 element = self.wait_until_clickable(self.CONTINENTS_LIST)40 select = Select(element)41 select.select_by_visible_text("Europe")42 def select_command(self):43 element = self.wait_until_clickable(self.COMMANDS_LIST)44 select = Select(element)45 select.select_by_visible_text("Wait Commands")46 def button_click(self):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!