rkb

Authentication with Selenium

4 posts in this topic

#1 ·  Posted

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:

 

            autoIt.Send("<user>");
            autoIt.Send("{TAB}");
            autoIt.Send("<password>");
            autoIt.Send("{Enter}");
 

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.

 

Kevin

Share this post


Link to post
Share on other sites



#2 ·  Posted

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>")

 

Example.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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)?

 

Authentication.jpg

autoit.jpg

Edited by rkb
Clarification

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

like 

Send("####",1)

 

Saludos

Edited by Danyfirex

 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
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