def test(data): actions.navigate(data.env.url + 'elements/') browser = actions.get_browser() checkbox_not_checked = browser.find('#unselected-checkbox') checkbox_checked = browser.find('#selected-checkbox') radio_not_checked = browser.find('#exampleRadios2') # checkbox not checked actions.verify_element_not_checked(checkbox_not_checked) checkbox_not_checked.check() actions.verify_element_checked(checkbox_not_checked) # checkbox already checked actions.verify_element_checked(checkbox_checked) checkbox_checked.check() actions.verify_element_checked(checkbox_checked) # radio button not checked actions.verify_element_not_checked(radio_not_checked) radio_not_checked.check() actions.verify_element_checked(radio_not_checked) radio_checked = radio_not_checked # radio button already checked radio_checked.check() actions.verify_element_checked(radio_checked) # try to check an element not radio or checkbox msg = 'Element #button-one is not checkbox or radiobutton' with expected_exception(Exception, msg): browser.find('#button-one').check()
def test(data): actions.navigate(data.env.url + 'elements/') browser = actions.get_browser() checkbox_not_checked = '#unselected-checkbox' checkbox_checked = '#selected-checkbox' radio_not_checked = '#exampleRadios2' # checkbox not checked actions.verify_element_not_checked(checkbox_not_checked) browser.check_element(checkbox_not_checked) actions.verify_element_checked(checkbox_not_checked) # checkbox already checked actions.verify_element_checked(checkbox_checked) browser.check_element(checkbox_checked) actions.verify_element_checked(checkbox_checked) # radio button not checked actions.verify_element_not_checked(radio_not_checked) browser.check_element(radio_not_checked) actions.verify_element_checked(radio_not_checked) radio_checked = radio_not_checked # radio button already checked browser.check_element(radio_checked) actions.verify_element_checked(radio_checked) # try to check an element not radio or checkbox try: browser.check_element('#button-one') assert False, 'Expected Exception' except Exception as e: assert 'Element #button-one is not checkbox or radiobutton' in e.args[ 0]
def test(data): actions.navigate(data.env.url + 'elements/') actions.verify_element_checked('#selected-checkbox') actions.verify_element_checked('#unselected-checkbox') golem_steps.assert_last_error( 'element #unselected-checkbox is not checked') actions.verify_element_checked('#exampleRadios1') actions.verify_element_checked('#exampleRadios2') golem_steps.assert_last_error('element #exampleRadios2 is not checked')
def test(data): actions.navigate(data.env.url + 'elements/') actions.verify_element_checked('#selected-checkbox') try: actions.verify_element_checked('#unselected-checkbox') except Exception as e: assert 'element #unselected-checkbox is not checked' in e.args[0] actions.verify_element_checked('#exampleRadios1') try: actions.verify_element_checked('#exampleRadios2') except Exception as e: assert 'element #exampleRadios2 is not checked' in e.args[0]
def test(data): actions.navigate(data.env.url + 'elements/') browser = actions.get_browser() checkbox_checked = browser.find('#selected-checkbox') checkbox_not_checked = browser.find('#unselected-checkbox') radio_checked = browser.find('#exampleRadios1') # checkbox not checked actions.verify_element_not_checked(checkbox_not_checked) checkbox_not_checked.uncheck() actions.verify_element_not_checked(checkbox_not_checked) # checkbox already checked actions.verify_element_checked(checkbox_checked) checkbox_checked.uncheck() actions.verify_element_not_checked(checkbox_checked) # uncheck a radio button (error) actions.verify_element_checked(radio_checked) with expected_exception(Exception, 'Element #exampleRadios1 is not checkbox'): radio_checked.uncheck() # try to uncheck an element not checkbox with expected_exception(Exception, 'Element #button-one is not checkbox'): actions.get_browser().find('#button-one').uncheck()
def test(data): actions.navigate(data.env.url + 'elements/') checkbox_checked = '#selected-checkbox' checkbox_not_checked = '#unselected-checkbox' radio_checked = '#exampleRadios1' # checkbox not checked actions.verify_element_not_checked(checkbox_not_checked) actions.uncheck_element(checkbox_not_checked) golem_steps.assert_last_step_message( 'Uncheck checkbox {}'.format(checkbox_not_checked)) actions.verify_element_not_checked(checkbox_not_checked) # checkbox already checked actions.verify_element_checked(checkbox_checked) actions.uncheck_element(checkbox_checked) actions.verify_element_not_checked(checkbox_checked) # uncheck a radio button (error) actions.verify_element_checked(radio_checked) with expected_exception(ValueError, 'Element #exampleRadios1 is not checkbox'): actions.uncheck_element(radio_checked) # try to uncheck an element not checkbox with expected_exception(ValueError, 'Element #button-one is not checkbox'): actions.uncheck_element('#button-one')