Best Python code snippet using lettuce_webdriver_python
web_utils.py
Source:web_utils.py
...192 Log in the Service Directory site using the default credentials.193 :param step: current Lettuce step.194 """195 lettuce_webdriver.webdriver.goto(step, world.config["django"]["base_web_url"] + "/")196 lettuce_webdriver.webdriver.fill_in_textfield(step, "username", world.config["django"]["webuser"])197 lettuce_webdriver.webdriver.fill_in_textfield(step, "password", world.config["django"]["webpassword"])198 lettuce_webdriver.webdriver.press_button(step, "Sign in")199 time.sleep(1.0)200 lettuce_webdriver.webdriver.see(step, "Service Directory - Home")201 def fill_in(self, step, field, value):202 """203 Fill in with the given value in the given field.204 :param step: current Lettuce step.205 :param field: id of the field to be filled.206 :param value: text to fill in the field.207 """208 value = self.parse_variables(value)209 lettuce_webdriver.webdriver.fill_in_textfield(step, field, value)210 def the_title_should_be(self, step, title):211 time.sleep(1.0)212 assert world.browser.title == title213 def close_browser(self, ):214 """215 Close the navigator window.216 """217 world.browser.quit()218 def parse_variables(self, template):219 """220 Build a string with the right values in the placeholders of the template221 provided.222 :param template: template to set the corresponding values.223 :return The string built...
web_steps.py
Source:web_steps.py
...121@step('I should see a form that goes to "(.*?)"$')122def see_form(step, url):123 return world.browser.find_element_by_xpath('//form[@action="%s"]' % url)124@step('I fill in "(.*?)" with "(.*?)"$')125def fill_in_textfield(step, field_name, value):126 with AssertContextManager(step):127 text_field = find_field(world.browser, 'text', field_name) or \128 find_field(world.browser, 'textarea', field_name) or \129 find_field(world.browser, 'password', field_name) or \130 find_field(world.browser, 'datetime', field_name) or \131 find_field(world.browser, 'datetime-local', field_name) or \132 find_field(world.browser, 'date', field_name) or \133 find_field(world.browser, 'month', field_name) or \134 find_field(world.browser, 'time', field_name) or \135 find_field(world.browser, 'week', field_name) or \136 find_field(world.browser, 'number', field_name) or \137 find_field(world.browser, 'range', field_name) or \138 find_field(world.browser, 'email', field_name) or \139 find_field(world.browser, 'url', field_name) or \...
webdriver.py
Source:webdriver.py
...103@step('I should see a form that goes to "(.*?)"$')104def see_form(step, url):105 return world.browser.find_element_by_xpath('//form[@action="%s"]' % url)106@step('I fill in "(.*?)" with "(.*?)"$')107def fill_in_textfield(step, field_name, value):108 with AssertContextManager(step):109 text_field = find_field(world.browser, 'text', field_name) or \110 find_field(world.browser, 'textarea', field_name) or \111 find_field(world.browser, 'password', field_name)112 assert_false(step, text_field is False,'Can not find a field named "%s"' % field_name)113 text_field.clear()114 text_field.send_keys(value)115@step('I press "(.*?)"$')116def press_button(step, value):117 with AssertContextManager(step):118 button = find_button(world.browser, value)119 button.click()120@step('I check "(.*?)"$')121def check_checkbox(step, value):...
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!!