I use the phantomjs webdriver to fill a text box on a webpage, clicking on a button, such as unable to perform an action I'm Headless Execution.
requires 'water-webdriver' b = water :: browser. New: Phatamaz Bijito "google.com" b.title # Google b.text_field (: id = & gt; "Lst-ib") set "Avinash"
then fills the text box Time, I'm facing the problem below.
Watir :: Exception :: UnknownObjectException: Unable to detect element {: id = & gt; "Lst-ib",: TAG_NAME = & gt; "Input or Text Area" ,: Type = & gt; "(Any text type)"} `assert_exists' /Ruby/Gems/2.0.0/gems/watir-webdriver-0.6.10/lib/watir Library / from /Library/Ruby/Gems/2.0.0/gems -webdriver / elements / element.rb: 508: in /watir-webdriver-0.6.10/lib/watir-webdriver/user_editable.rb:11:in ` '(IRB) from: 16 / usr / bin / IRB: 12: In & lt; Main & gt; ' Set
The same script works fine when using Firefox without headless execution. Please tell me if there is any suggestion here.
Below are my gem versions:
1. Water-WebDriver (0.6.10)
2. Selenium-WebDriver (2.45.0, 2.43.0)
3. Phatcom 2.0.0
The main problem is that it looks like HTML by Firefox PhantomJS is different from. The HTML of the text field in Firefox: In contrast, PhantomJS shows: Note that there is no ID attribute in the PhantomJS. As a result, it is understood that the detection of the field causes its ID to fail. You must use a different locator for example: or
& lt; input spellcheck = "false" dir = "ltr" style = "border: medium none; padding: 0px; margin: 0px; height: auto; width: 100%; background: url (& amp; quot; data: image / gif; base 64, R0lGODlhAQABAID / AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw% 3% D 3 and D amp; quot;) repeat scroll 0% 0% transparent; position: absolute; Z- index dropped 6; 0 pixels; Profile: medium none ; "aria- autocomplete =" both "role =" tell the "aria-haspopup =" false "class =" gsfi lst-df "id =" lst- IB "maxlength =" 2048 "name =" q "automatic : Full = "off" heading = "search" value = "" RIA-label = "search" type = "text" & gt;
& lt; Input style = "color: rgb (0, 0, 0); margin-top: 0 px; margin -Right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding- right : 8px; padding-bottom: 0px; padding-left: 6px; vertical-align: top; outline style: none; outline-width: initial; outline-color: initial; "auto-integer =" off "square =" Lst "value =" "title =" Google search "Maximum length =" 2048 "name =" q "size =" 57 "Dir =" ltr "spell check =" wrong "& gt;
b.text_field (: name = & gt; "q"). Set ("Avinash")
b.text_field (: title = & gt; "Google search") set ("Avinash") < / Code>
No comments:
Post a Comment