cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnCe01
Regular Visitor

Selenium login to popup

I'm using an UI flow web app to navigate to a url and retrieve information on that page. The page is behind a login and upon navigating to the page the browser (below example is in chrome) shows a popup at the top of the page. 

AnCe01_0-1593442892759.png

 

My question

How can you fill in the login credentials in selenium? I tried the method where you enter http://Username:Password@SiteURL as a Target, but this doesn't work for the specific url I'm using. Is there a different method through which you can give the credentials in selenium? 

 

The login credentials for the website I'm entering and the login credentials from my machine, which are used by the flow to run the flow, are not the same. 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @AnCe01,

If during the playback the script stops at the authentication popup it means that your credentials are invalid. I just tried with special characters in my password, and I managed to run the Selenium Flow too: I needed to encode the password, as you mentioned, using a tool like this one. Make sure to also update the URL with the credentials in the "open" command of the script, because if you edit your script afterwards, editing the target URL is not enough as some steps have been already recorder with the old URL.

WSH_0-1594043486100.png

 

The authentication is a bit hard to debug as the recording behaves differently from the playback. To get specific help on your scenario, I would suggest you to open a support ticket, as it would allow to diagnose issues in your recording.

 

About your licensing issue for WinAutomation, did you follow the license reset steps described in the troubleshooting section? https://docs.microsoft.com/en-us/power-automate/ui-flows/create-processes#troubleshooting-winautomat...

There are guidelines to know if you have the appropriate license and how to reset the WinAutomation account used for licensing.

 

View solution in original post

6 REPLIES 6
WSH
Microsoft
Microsoft

Hi @AnCe01,

When you mentioned that http://Username:Password@SiteURL didn't work, did you try to reach this URL directly from Chrome first, without using UI flows? Did you try both "http" and "https"? What is the actual error? Because this should work, as the popup looks like a Basic Authentication popup.

There is no other way to perform this authentication using Selenium, as the popup is handled by the browser directly, and not the web page.

Though, I noticed that you cannot create a Web UI flow while providing the credentials with this pattern, so I'm going to create a bug for the owning team.

Another possible solution could be to use WinAutomation to record your script instead of Selenium, now that Softomotive has been acquired by Power Automate. Here is a link to help you get started: https://docs.microsoft.com/en-us/power-automate/ui-flows/create-processes

Tell me if you manage to connect to your web page, passing the credentials in the URL using Chrome.

Best regards,

AnCe01
Regular Visitor

Hi @WSH

 

Thank you for your reply. To answer your first question when going to the url without using UI flow in Chrome you have to use https as http doesn't work. When you first go to the url you receive the same popup, but after login in it remembers the username password and you don't have to login again as long as you keep the browser open. After closing Chrome completely you do have to re-enter your username password again.

 

I tried to first manually go to Chrome fill in the username password and then let the UI flow run, but this doesn't work as a new screen is opened in which it shows the popup again. 

 

The UI flow has now been build using the https version of the url and as I wasn't able to use the http://Username:Password@SiteURL  I build the UI flow skipping this step (meaning I manually logged in and continued the process). This is why the error message doesn't come as a surprise to me as it is not able to reach the destination page I have given it.  

 

 

 

 

The error message I receive:

{
  "error": {
    "code": "StepTimeout",
    "message": "Command execution exceeded the step timeout 00:00:10. Message: 'No frame found in current window by locator: 'index=1'.'."
  }
}

 

 

 

Error details: 

Command execution exceeded the step timeout 00:00:10. Message: 'No frame found in current window by locator: 'index=1'.'. 

 

Thank you for the WinAutomation suggestion I'm going to look in to this to see if this might be a solution for me. 

Hi @AnCe01,

Thanks for the precisions. My question was rather about finding why putting the credentials in the URL doesn't work for you, because this should solve your issue.

I just tested it on my side for another thread with the same issue and I managed to log into the website even during playback. Here are the steps I followed:

  • Create a new Web UI flow and put the URL of your website without the credentials. We currently have an opened bug on that (you cannot create the UI flow with a URL of format user:password@website.com).
  • In Selenium IDE, change the target URL to include your credentials:
    WSH_4-1593610437589.png

     

  • Record your script. As you put your credentials in the URL just before, you should not be prompted for credentials. If that's the case, your credentials must be wrong, stop the recording, double check your credentials and restart the recording from the beginning.
  • Then save your recording. Once saved, edit this recording and make sure that Selenium IDE still displays the URL with your credentials.
  • If that's the case, just close the IDE and use the UI flow as usual in your Flow, it should work.

Does it work for you following my steps?

Best regards,

AnCe01
Regular Visitor

Hi @WSH ,

 

I followed your instructions and created a flow first without credentials and later on added them. I had to play around a bit with the username password combination as those included special characters  and I realized that those had to be encoded in the url because when you don't encode the special characters in the username/password UI flow doesn't allow you to save your flow see error message

AnCe01_0-1594023613655.png

 

After encoding my username/password UI flow continues to navigate to the url. However, it never gets passed the username/password popup as for some reason the username and password are not being filled in. It does recognize the following steps as it sets the screensize I gave it and it also looks for the first indicator I gave it. 

 

{
  "error": {
    "code": "StepTimeout",
    "message": "Command execution exceeded the step timeout 00:00:10. Message: 'No frame found in current window by locator: 'index=1'.'."
  }
}

 

Error details:

Command execution exceeded the step timeout 00:00:10. Message: 'No frame found in current window by locator: 'index=1'.'.

 

In the url I did the following https://[encoded username]:[encoded password]@url

I tried to run the flow in both Chrome and Microsoft Edge

 

 

I have also tried to use WinAutomation, but unfortunately it doesn't work for me as the Microsoft account that is linked to my laptop doesn't contain the correct license and WinAutomation tries to use those credentials which means that it gives the error message that you need the correct license to be able to use WinAutomation and shuts down before it is possible to change to a different Microsoft account with the correct credentials. 

 

 

Best regards

 

Hi @AnCe01,

If during the playback the script stops at the authentication popup it means that your credentials are invalid. I just tried with special characters in my password, and I managed to run the Selenium Flow too: I needed to encode the password, as you mentioned, using a tool like this one. Make sure to also update the URL with the credentials in the "open" command of the script, because if you edit your script afterwards, editing the target URL is not enough as some steps have been already recorder with the old URL.

WSH_0-1594043486100.png

 

The authentication is a bit hard to debug as the recording behaves differently from the playback. To get specific help on your scenario, I would suggest you to open a support ticket, as it would allow to diagnose issues in your recording.

 

About your licensing issue for WinAutomation, did you follow the license reset steps described in the troubleshooting section? https://docs.microsoft.com/en-us/power-automate/ui-flows/create-processes#troubleshooting-winautomat...

There are guidelines to know if you have the appropriate license and how to reset the WinAutomation account used for licensing.

 

AnCe01
Regular Visitor

@WSH 

 

THANK YOU! It works! 🎊

 

So what I didn't do in my previous attempt is change the url at the top (the one that is used to run) I only changed the url which had the open command. Also the encoding tool you gave encoded the characters slightly different so that worked better. 

 

 

Thank you for your help!

 

Kind regards

 

 

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,367)