1

The popup comes when we navigate to website and asks for authentication.Something like this. Please let me know how to handle the alert with username and pass, that pops up as this pop up could not be distinguished with firebug etc

I already tried "INPUT TEXT into prompt" #input text into prompt https://username:password@url.com but I get error that There is no alert present. However when I use function Alert should be present it gets passed

I am using robot framework and Selenium2Library.

Sammy
  • 77
  • 2
  • 9

1 Answers1

0

What you are running into is called BASIC web server authentication. While searching on SO there are a number of similar questions that have been asked over time. This particular one is nice as it has several solution approaches that can be tried.

As the popup is technically not part of the page's DOM, this can not be addressed using xpath. There are roughly two approaches:

  1. Fill in the text boxes using a key stroke simulator like SendKeys.
  2. Prevent the popup from appearing.

In this case you're already on your way for the second one. By including the username and password in the url, the popup is prevented. The following Robot Script uses that example to access a local page that is secured by basic authentication using this tutorial.

*** Settings ***
Library    Selenium2Library

*** Test Cases ***
Test Chrome
    Create Webdriver    Chrome
    Go To    http://admin:admin@localhost:8090/basic-auth/
    Capture Page Screenshot    
    [Teardown]  Close All Browsers

As the popup is prevented, there is no need separately input the username and password.

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
  • I tried the same `Create Webdriver Chrome Go To http://admin:admin@localhost:8090/basic-auth/` for the website I want to automate, but it did not do anything, as in, it opened the browser and took to the website but it did not type the username and password in the area. And as you can see in my question I was previously using the same approach but it did not work. @A.Kootstra Although this approach works when I use normal selenium framework with Java or Python but not sure why it does not work with Robot Framework! – Sammy Jun 04 '17 at 15:58
  • But are you logged into the application successfully? You would not see the pop-up at all with this approach. You'd directly go to the desired page/site and that is the proof of success. – A. Kootstra Jun 04 '17 at 17:09
  • Thanks, it worked, I was using http previously though it works with https. – Sammy Jun 05 '17 at 05:14
  • i have similar situation but with FTP , whenever i tried to pass the same like ftp://admin:admin@[IP of URL], it is not recognizing the username and password. No username and password is added to the ftp dialog. Any inputs here. – hardik dave Aug 21 '20 at 07:22
  • This is different from the original question and should be asked as a separate question. – A. Kootstra Aug 21 '20 at 07:33