Jump to content

Authentication with Selenium


Recommended Posts

I am using Selenium and it has been suggested that I use AutoIT to enter text in the dialog that pops up for authentication. Here is my code:



This seems to work for the user name but I am guessing since the password contains a '#' character only part of the password is being sent. Should the '#' character be escaped somehow?


Thank you.



Link to comment
Share on other sites

If you're going to interact with a window it'd be better to use ControlSetText instead of Send. If you've got the full version of autoit installed open up the AutoIt Window Info Tool and get the window title and the control ids of the two input boxes for your window. Like in my example image, to fill in the username (because that's the info I have in the image)

ControlSetText("Authentication", "", "[Class:Edit; Instance:1]", "<user>")

And the password control is instance 2 (not in the screenshot, but that's what I know because I created that window). So it would be like this

ControlSetText("Authentication", "", "[Class:Edit; Instance:2]", "<password>")



Link to comment
Share on other sites

I am not sure if I follow. I have attached the dialog in question and it seems if I use the "Finder Tool" nothing changes for either the user or password input.

Maybe this will come from the reply but I don't understand all of the 4 arguments for ControlSetText (title, text, control, controlText)?




Edited by rkb
Link to comment
Share on other sites

Hello. If you're site use Basic Auth You can pass credentials in the URL like https://username:password@www.something.com:8080


Edit: Main question answer.

If you need to send specials character add SEND_RAW flag.





Edited by Danyfirex
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...