lettuce_webdriver icon indicating copy to clipboard operation
lettuce_webdriver copied to clipboard

Targeting field by type "email" and "password"

Open jabrake opened this issue 11 years ago • 1 comments

Hello,

I tried modifying the "find_field_by" function to find a text field by type, and later "clear" and "send_keys" in order to fill out a form. Specifically, I'm trying to target two fields: type="email" and type="password" but I get the following error message (doesn't get past filling the e-mail field in the test):

AssertionError: And I fill in field with type "email" with "[email protected]", failed because: Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace: Method fxdriver.preconditions.visible threw an error in file:///var/folders/xo/xoXGh2V+E70Th0NlE8tkIk+++TM/-Tmp-/tmpjm7c8r/extensions/[email protected]/components/command_processor.js

This is the function I'm using to target these fields:

@step('I fill in field with type "(.?)" with "(.?)"') def fill_in_textfield_by_type(step, field_type, value): with AssertContextManager(step): text_field = find_field_by_type(world.browser, field_type) assert_false(step, text_field is False,'Can not find a field with type "%s"' % field_type) text_field.clear() text_field.send_keys(value)

And the "find_field_by_type" function:

def find_field_by_type(browser, attribute): xpath = "//input[@type='%s']" % attribute elems = browser.find_element_by_xpath(xpath) return elems

Any suggestions on creating a function to properly target these elements and fill them out?

Thanks, Jorge

jabrake avatar Apr 11 '13 20:04 jabrake

It is visible, right?

danni avatar Sep 30 '13 00:09 danni