SecureAuth Sign In pop up. How to handle

Hi Robot Framework experts.

Using Robot Framework I had automated a portal which uses secureAuth for sign in and able to execute the tests in local desktop no Single sign on issue as I already signed into company portal , so scripts automatically sign’s into the application.

But I have to run these tests in a remote server and when the script clicks on Login in button Secureauth displays a pop up as seen in the attached screenshot. I am unable to enter text in the pop up or do anything with script.

Tried:

  1. Sending ID and password in URL( https://ID:Password@uri ) did not work.
  2. Tried Alert keywords did not work. I guess it is not a alert at all.

Can some one point me in right direction Please.

Thank you for your time…

Hi,

I assume that you use SeleniumLibrary…
(It is always important to also tell us which Library you use, because Robot Framework itself can not automate WebBrowser. Libraries can)

With SeleniumLibrary one deprecated known possibility is, to send the user and pwd as url, what you already tried!
You are right. Basic Auth are not alerts.

You can Google for Basic Auth Selenium but there are pretty old answers. Not sure if they are still working.

One solution would be to leave SeleniumLibrary behind and switch to Browser library.

That brand new modern library has the possibility to add Basic Auth headers to a new Context.

2 Likes

You an use Windowsapplication driver that comes as a part of Appium.

Tried using Sikulilibrary for ROBOT Framework, it is working fine in desktop, but would not run in remote linux server in browser headless mode.

Still stuck with this issue. Currently exploring what @René suggested.

How is it going with Browser?

You have to use

https://marketsquare.github.io/robotframework-browser/Browser.html#New%20Context

New Browser
New Context    httpCredentials={'username': 'admin', 'password': '123456'}
New Page       https://example.com
2 Likes

@René Thank you for the sample script.
I was skeptical about Browser Library until you sent me those 3 lines of code, and after seeing your code I felt it can’t be that simple to handle Basic Auth popup. I felt this way about the popup coz there are many unconcluded posts about it in all code forums, and since last week I spent some time building a crude solution to get token and set cookie when opening the browser. :face_with_head_bandage:

I must apologize for ignoring your suggestion to "leave SeleniumLibrary behind ". I taught how else I will handle the browser if I leave selenium and just ignored your suggestion. Now I understand its due to my ignorance. :slight_smile:

Browser Library handled Basic Auth pop up like a charm … thank you very much for suggesting Browser library. now I am moving all my Selenium keywords to equivalent Browser Library keywords.

I had executed a few test cases with Browser lib keywords and noticed tests are running faster and less flaky. I don’t need waits, close browser, etc…any more.

Thank you very much… :handshake: :handshake:

4 Likes

The Browser library does not support Chrome and the web application I’m testing is working only on chrome.

Hey cool!!!:performing_arts:

Nice that you like it!!! :heart::blue_heart::purple_heart:

Hi hassand,

Google Chrome is basically the same as Chromium. Chromium is the open source Version of Chrome. It only does not have the google telemetry tracking.

So when you use Browser library you can use Chromium. I think your System under Test should work with it technically. If your developers request exactly “Chrome” that is a bug. Imho.

Cheers

2 Likes

How do i import the Browser library into my robot framework?

All infos should be at https://robotframework-browser.org

The only consistent workaround that I have applied is to use AutoItLibrary with custom firefox profile. Step 1 to 3 below are manual steps. Step 4 onward to be applied on RIDE. The pre-condition is Selenium and AutoItLibrary already installed.

  1. First create your own firefox profile.
  2. Then launch firefox with the new profile created, and launch YOUR_URL you want to test.
  3. When the authorization alert come out, manually input the username & password and click enter or proceed. This will save the username & password to this browser cache/cookie…
  4. Next, on RIDE →
  • Open Browser YOUR_URL firefox ff_profile_dir=${your_new_profile_dir}
  • Sleep 2s
  • AutoItLibrary.Send {ENTER}

When the browser is open, you just need to press enter on the active window (AutoItLibrary does it), the username & password are automatically populated since they are already in cache.

Hi Temizzi,

René’s solution was much easier and more reliable.

But in your case, there are so many possible solutions that would be better, some examples:

  • your current solution doesn’t appear to even need autoit, but since you have it you could use that to automate the credentials dialogue
  • if you are happy to store the user credentials in a firefox profile, then you could do this step manually, save the profile to a known location (same directory as your robot files?) then before you call open browser, use the builtin keywords to copy the profile to the the place firefox stores user profiles, then use pass an option to firefox to launch using that profile.

In my opinion any solution that requires manual steps is prone to errors and should be avoided at all costs.

Dave.

Hi damies13,

Yes Rene’s solution is simpler by using Browser library but my solution is ideal for someone who still want to use Selenium Library. Like my case, I cannot simply migrate to use browser library because I already have written hundred of test cases written with Selenium Library and the team use it. It is a matter of preference and also requires decision from lead or organization if I need to change to browser’s library because I need to put more effort to rewrite my existing test cases…

As for manual intervention in my approach, it requires only once, as I need to store user credentials manually in profile, later that profile is alwalys loaded whenever I use open browser (with ff_profile_dir). Besides, I always have a separate firefox profile when testing with robot and it is not prone to error at all… I believe many also use their own profile (ff_profile_dir) for robot.

There always more than 1 workaround for an issue and the best solution is when selenium webdriver can handle this authorization alert (basic auth, etc). Anyone has any idea when we can have this fix?

Ah I see, I got the impression you were doing steps 1-3 every time you needed to run your tests and that would get annoying.

I Agree SeleniumLibrary really needs a solution for those authentication dialogues.

Something that might help you migrate to Browser Library if you want to, from when I did it, actually a few of the keywords are the same so those don’t even need to be changed. I also created a some keyword words that simply converted the selenium keywords I used a lot, to browser keywords for example:

Wait until page does not contain element
	[Arguments]	${locator}
	Wait For Elements State 	${locator}	detached

You can see all of the one’s I used here:
(TestDataTable/TestDataTable-GUI_Browser_chromium.robot at master · damies13/TestDataTable · GitHub)

I actually contemplated whether it would be worthwhile creating a robot keyword library specifically for simulating all the Selenium Keywords with Browser Library, but I don’t use either enough to need it, feel free to take the idea and run with it if you want.

Dave.

OH cool, that robot keywords simulating selenium keywords using Browser Library might be useful for temporary solution. The long-term solution is to have selenium keywords the ability to perform the same actions as Browser Library does. I have not used Browser Library before, need to study it more and I have no idea what differ between these two…

I would not expect any change in SeleniumLibrary to handle these dialogues as it is just a wrapper around the core Selenium Webdriver code, and given the number of issues people have getting Selenium Webdriver code to work with these dialogues and the number of issues as it keeps breaking in various releases of Selenium Webdriver.

I found this article which appears the be for Selenium Webdriver Java Code:

Note even there option 2 is use Autoit

I also found this issue:

The post on the 5th May 2015 has links to various methods of getting it to work.

Obviously with these links you will need to figure out how to translate those suggestions to the RF keywords, the theory being it should be possible, but it looks like it’s never going to be reliably easy in Selenium.

What impressed me with BrowserLibrary was that they supported in the first version getting the http response codes (when a server returns http 404, 500 etc) which the Selenium developers have refused to do for many years (I have seen several issues raised on this were closed as won’t be supported), for me this is enough reason to migrate to BrowserLibrary.

Dave.

I had working demo that injected selenium-wire for SeleniumLibrary (in use with my testability plugin) where whole network traffic was accessible by keywords. Also, it makes a huge different to catch “ongoing api calls” to be able to see if requests have completed or not. But that lead to nowhere …

@René I after reading about your suggestion I tried installing the browser library and I used the following commands:
pip install robotframework-browser
and then
rfbrowser init
It went through successfully, however when I an trying to run a simple login test using browser library I get error saying “Importing library ‘Browser’ failed: ModuleNotFoundError: No module named ‘Browser’”
I was using selenium library prior to using browser library. can you provide some insights on resolving this error?
Thanks

Hello Mr.Rene

I have a similar problem, except instead of typing in credentials, a popup comes when one wants to confirm an action, and there is approve and cancel buttons. I have tried everything I know and googled till my fingers hurt, but I have been unable to get Browser recognize that popup.

Any change you would know how to make Browser handle this?
Can it take control of that new window it cant find and interact with that element it cant see?