Best Python code snippet using lettuce_webdriver_python
webdriver.py
Source:webdriver.py  
...194        elem = world.browser.find_element_by_xpath(str(195            '//label[normalize-space(text()) = "%s"]' % label))196        elem.click()197@step(r'Element with id "([^"]*)" should be focused')198def element_focused(step, id):199    """200    Check if the element is focused201    """202    elem = world.browser.find_element_by_xpath(str('id("{id}")'.format(id=id)))203    focused = world.browser.switch_to_active_element()204    assert_true(step, elem == focused)205@step(r'Element with id "([^"]*)" should not be focused')206def element_not_focused(step, id):207    """208    Check if the element is not focused209    """210    elem = world.browser.find_element_by_xpath(str('id("{id}")'.format(id=id)))211    focused = world.browser.switch_to_active_element()212    assert_false(step, elem == focused)...expectations.py
Source:expectations.py  
...234        if len(context.behave_driver.secondary_handles) < 1:235            raise AssertionError('No secondary handles found!')236        raise AssertionError("The url '{}' was not found in any handle")237@then('I expect that element "([^"]*)?" is( not)* focused')238def check_element_focused(context, element, negative):239    element_focused = context.behave_driver.element_focused(element)240    if negative:241        assert not element_focused242    else:243        assert element_focused244@then('I expect that a (alertbox|confirmbox|prompt)( not)* contains the text "([^"]*)?"')245def check_modal_text_contains(context, modal_type, negative, text):246    alert_text = context.behave_driver.alert.text247    if negative:248        assert not text in alert_text249    else:250        assert text in alert_text251@then('I wait on element "([^"]*)?"(?: for (\d+)ms)*(?: to( not)* (be checked|be enabled|be selected|be visible|contain a text|contain a value|exist))*')252def wait_for_element_condition(context, element, milliseconds, negative, condition):253    if milliseconds:...__init__.py
Source:__init__.py  
1# æ»å¨æ¹åçåå¼èå´2DIRECTION_UP = 'up'3DIRECTION_DOWN = 'down'4DIRECTION_LEFT = 'left'5DIRECTION_RIGHT = 'right'6# å表é³ä¹çåå¼èå´7LIST_INDEX_1 = 18LIST_INDEX_2 = 29LIST_INDEX_3 = 310LIST_INDEX_4 = 411LIST_INDEX_5 = 512# å
ç´ å±æ§çåå¼èå´13ELEMENT_TEXT = 'text'14ELEMENT_ID = 'resourceId'15ELEMENT_CLASS = 'class'16ELEMENT_CONTENT_DESC = 'content-desc'17ELEMENT_CHECKED = 'checked'18ELEMENT_SELECTED = 'selected'19ELEMENT_FOCUSED = 'focused'20ELEMENT_CLICKABLE = 'clickable'21ELEMENT_SCROLLABLE = 'scrollable'22ELEMENT_BOUNDS = 'bounds'23ELEMENT_SIZE = 'size'24# å°é©¬åºç¨ç䏿å25MUSIC = 'é³ä¹'26XTING = 'çµå°'27SERVICE = '车è¾ç®¡å®¶'28APP = '车åºç¨'29SHOP = 'å¥è
¾åå'30PERSONAL = '个人ä¸å¿'...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!!
