tag:support.arachni-scanner.com,2012-07-01:/discussions/problems/4239-login_script-error-using-xpath-with-watir-apiArachni: Discussion 2018-10-19T07:41:58Ztag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-29T15:06:23Z2017-03-29T15:06:23Zlogin_script error using xpath with watir api<div><p>I don't think you are using XPath properly, try removing <code>ebInput.</code> and <code>ebBtn.eaLogin-formButton.</code> from the expressions.</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-29T16:17:37Z2017-03-29T16:17:37Zlogin_script error using xpath with watir api<div><p>No, I got the same error.</p></div>Thierry Beauquiertag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-29T17:14:29Z2017-03-29T17:14:29Zlogin_script error using xpath with watir api<div><p>Can you please place the following after the <code>goto</code> call and show me the output?</p>
<pre>
<code>puts browser.source</code>
</pre></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-29T20:28:38Z2017-03-29T20:28:39Zlogin_script error using xpath with watir api<div><p>Sorry but not much useful information</p>
<p>`[~] No checks were specified, loading all. [~] No element audit options were specified, will audit links, forms, cookies, UI inputs, UI forms, JSONs and XMLs.</p>
<p>[<em>] Initializing... [</em>] Preparing plugins... [~] Login script: Running the script. #<a>Watir::Source:0x00000005599278</a> [-] [utilities#exception_jail:428] Session: [ArgumentError] expected Hash or (:how, 'what'), got ["user"] [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/arachni-1.5.1/components/plugins/login_script.rb:29:in <code>eval' [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/svg_elements.rb:699:in</code>set' [-] [utilities#exception_jail:428] Session: (eval):17:in <code>block in prepare' [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/arachni-1.5.1/components/plugins/login_script.rb:29:in</code>eval' [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/arachni-1.5.1/components/plugins/login_script.rb:29:in <code>block in prepare' [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/arachni-1.5.1/components/plugins/login_script.rb:47:in</code>call' [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/arachni-1.5.1/components/plugins/login_script.rb:47:in <code>block in prepare' [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/arachni-1.5.1/lib/arachni/session.rb:322:in</code>call' [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/ar `</p></div>Thierry Beauquiertag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-29T21:42:45Z2017-03-29T21:42:47Zlogin_script error using xpath with watir api<div><p>I got the printout by using "puts browser.html" instead and noticed that the element I need to access is contained inside</p>
<div></div>
and it is not displayed by watir but can be seen when using Inspector from FF. So watir does not load the js container dynamically but only the pure html source ?
<p>I sent you the js code inside</p>
<div></div>
in login.html and see attachment for arachni output
<p>Regards<br>
Thierry</p></div>Thierry Beauquiertag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-30T08:13:23Z2017-03-30T08:13:23Zlogin_script error using xpath with watir api<div><p>I'm assuming the container is populated by an AJAX call, in that case you will have to wait for the form elements to appear, see: <a href="http://www.rubydoc.info/gems/watir-webdriver/Watir%2FEventuallyPresent%3Await_until_present">http://www.rubydoc.info/gems/watir-webdriver/Watir%2FEventuallyPres...</a></p>
<p>If that doesn't work either then I'll need access to the webapp in order to debug it.</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-30T12:37:54Z2017-03-30T12:37:59Zlogin_script error using xpath with watir api<div><p>It timed out when looking for "username" text_field. If you have any other idea, let me know anyway I will ask design to confirm for the AJAX call and try to get help from them.</p>
<p>Unfortunately it is not possible to access the webapp from internet.</p>
<p>There is REST api also to access the webapp so my next step would be to scan it with arachni.</p>
<p>Thanks</p></div>Thierry Beauquiertag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-30T16:19:28Z2017-03-30T16:19:29Zlogin_script error using xpath with watir api<div><p>Talked to design and there is no AJAX involved just javascript. They are using also Selenium/webdriver with Java and they do as you suggest, waiting for the container to load before login.</p></div>Thierry Beauquiertag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-30T16:46:59Z2017-03-30T16:46:59Zlogin_script error using xpath with watir api<div><p>I have been able to get the container loaded in watir and being seen by arachni using the following in the login script</p>
<pre>
<code>browser.div(:id => "container").wait_until_present
puts browser.html
form = browser.form( name: 'loginForm')
form.text_field( name: 'username').set 'user1'
form.text_field( name: 'password').set 'password1'
form.submit</code>
</pre>
<p>However I got a another error from Selenium:<br></p>
<pre>
<code></body></html>
[-] [utilities#exception_jail:428] Session: [Selenium::WebDriver::Error::InvalidElementStateError] {"errorMessage":"Element is not currently interactable and may not be manipulated","request":{"headers":{"Accept":"application/json","Accept-Encoding":"gzip;q=1.0,deflate;q=0.6,identity;q=0.3","Connection":"close","Content-Length":"2","Content-Type":"application/x-www-form-urlencoded","Host":"127.0.0.1:6715","User-Agent":"Ruby"},"httpVersion":"1.1","method":"POST","post":"{}","postRaw":"{}","url":"/clear","urlParsed":{"anchor":"","query":"","file":"clear","directory":"/","path":"/clear","relative":"/clear","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/clear","queryKey":{},"chunks":["clear"]},"urlOriginal":"/session/c8201510-1567-11e7-b8f7-4710787239ef/element/:wdc:1490892114802/clear"}} (org.openqa.selenium.InvalidElementStateException)
[-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/arachni-1.5.1/components/plugins/login_script.rb:29:in <code>eval&#39;
[-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/response.rb:32:in</code>initialize'
[-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/http/common.rb:81:in <code>new&#39;
[-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/arachni-1.5.1-0.5.12/system/gems/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/http/common.rb:81:in</code>create_response'</code>
</pre></div>Thierry Beauquiertag:support.arachni-scanner.com,2012-07-01:Comment/422577902017-03-31T15:19:24Z2017-03-31T15:19:25Zlogin_script error using xpath with watir api<div><p>I think that I found the issue, the element (username, password) where already filled because of auto-complete (can be seen from FF) so just doing <code>form.submit</code> did the trick.</p>
<p>Discussion can be closed.</p>
<p>Regards</p></div>Thierry Beauquier