login_script error using xpath with watir api
Hi,
Got the following error [ArgumentError] expected Hash or (:how, 'what'), got ["username1"] when using login script with watir xpath API. When using text_field API, watir was not able to locate any element provided
(unable to locate element, using {:name=>"username", :tag_name=>"input or textarea", :type=>"(any text type)
Login script :
browser.goto "https://10.120.87.250/ng/login"
browser.element(:xpath => "//input[@class='ebInput.eaLogin-loginUsername']").set("username1")
browser.element(:xpath => "//input[@class='ebInput.eaLogin-loginPassword']").set("password1")
browser.element(:xpath => "//button[@class='ebBtn.eaLogin-formButton.eaLogin-form-submit']").click
I am using latest arachni version (1.5.1-0.5.12). Attached the complete arachni log and html form
Regards
Thierry
- login.html 14.5 KB
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Tasos Laskos on 29 Mar, 2017 03:06 PM
I don't think you are using XPath properly, try removing
ebInput.
andebBtn.eaLogin-formButton.
from the expressions.2 Posted by Thierry Beauqui... on 29 Mar, 2017 04:17 PM
No, I got the same error.
Support Staff 3 Posted by Tasos Laskos on 29 Mar, 2017 05:14 PM
Can you please place the following after the
goto
call and show me the output?4 Posted by Thierry Beauqui... on 29 Mar, 2017 08:28 PM
Sorry but not much useful information
`[~] No checks were specified, loading all. [~] No element audit options were specified, will audit links, forms, cookies, UI inputs, UI forms, JSONs and XMLs.
[] Initializing... [] Preparing plugins... [~] Login script: Running the script. #Watir::Source:0x00000005599278 [-] [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
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
set' [-] [utilities#exception_jail:428] Session: (eval):17:inblock 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
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:inblock 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
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:inblock 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
call' [-] [utilities#exception_jail:428] Session: /home/lmcthbe/Downloads/ar `5 Posted by Thierry Beauqui... on 29 Mar, 2017 09:42 PM
I got the printout by using "puts browser.html" instead and noticed that the element I need to access is contained inside
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 ?I sent you the js code inside
in login.html and see attachment for arachni outputRegards
Thierry
Support Staff 6 Posted by Tasos Laskos on 30 Mar, 2017 08:13 AM
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: http://www.rubydoc.info/gems/watir-webdriver/Watir%2FEventuallyPres...
If that doesn't work either then I'll need access to the webapp in order to debug it.
7 Posted by Thierry Beauqui... on 30 Mar, 2017 12:37 PM
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.
Unfortunately it is not possible to access the webapp from internet.
There is REST api also to access the webapp so my next step would be to scan it with arachni.
Thanks
8 Posted by Thierry Beauqui... on 30 Mar, 2017 04:19 PM
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.
9 Posted by Thierry Beauqui... on 30 Mar, 2017 04:46 PM
I have been able to get the container loaded in watir and being seen by arachni using the following in the login script
However I got a another error from Selenium:
10 Posted by Thierry Beauqui... on 31 Mar, 2017 03:19 PM
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
form.submit
did the trick.Discussion can be closed.
Regards
Tasos Laskos closed this discussion on 01 Apr, 2017 10:46 AM.