bbangert / lettuce_webdriver

Selenium webdriver for lettuce
MIT License
81 stars 32 forks source link

Targeting field by type "email" and "password" #22

Open jabrake opened 11 years ago

jabrake commented 11 years ago

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 "jorge@jorge.net", 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/fxdriver@googlecode.com/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

danni commented 10 years ago

It is visible, right?