My html structure is follow:
<input name="ctl00$ContentPane$Password" type="password" id="ctl00_ContentPane_Password">
From the UI this is how it looks:
My ruby script is follow:
browser.text_field(:id => 'ctl00_ContentPane_Password').wait_until_present(10)
- returns true
...well then this command:
browser.text_field(:id => 'ctl00_ContentPane_Password').set ('test')
- returns error message
Session: [Watir::Exception::UnknownObjectException] unable to locate element, using {:id=>"ctl00_ContentPane_Password", :tag_name=>"input or textarea", :type=>"(any text type)"}
Anyone is familiar with these type of ridiculous issues with Watir?
Then element is not visible. This happen because there might be two element with the same id and first one is hidden. So write this code and check it.
browser.text_fields(:id => 'ctl00_ContentPane_Password')[1].set 'test'
Remember, you don't need to use wait_until_present
because waiting is automatic
browser.input(id: 'ctl00_ContentPane_Password').send_keys('your-text')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.