suppressing basic authentication login

135 views
Skip to first unread message

Vasil Arnaudov

unread,
Apr 29, 2015, 9:27:54 AM4/29/15
to seleniu...@googlegroups.com
one  way to suppress login us to use "user:pass...@somewhere.som"
as base url. But this does not work when the username is an e-mail. I've tried with "user%40email.com:pass...@somewhere.som" but does not work. 
Is there a proper way to do this?

Also the alerts handling does not work :

                driver.get("https://my.link/"); 
                WebDriverWait wait = new WebDriverWait(driver, 10); 
                wait.until(ExpectedConditions.alertIsPresent()); 
                //System.out.println(); 
                Alert alert = driver.switchTo().alert(); 
                alert.authenticateUsing(new UserAndPassword("USERNAME""PASSWORD")); 
                System.out.println(alert);



Any ideas?

Best regards.

brandon garlock

unread,
Apr 29, 2015, 9:29:18 PM4/29/15
to seleniu...@googlegroups.com
What browser are you using? I have never tried it but it looks like historically  IE does not support username in url. https://support2.microsoft.com/default.aspx?scid=kb;%5bLN%5d;834489

Abhishek Singh

unread,
Apr 30, 2015, 1:40:12 AM4/30/15
to seleniu...@googlegroups.com
Hi Vasil,
I would recommend you to first test that string as it is by placing the string directly into browser.  [http://us...@mail.com:pass...@somewhere.com]
If that works in the browser directly, then you can think about how to handle the same in Selenium. You may have to lower the security setting of the particular browser in case you are encountering security issues while doing that.


Regards,
Abhishek

Vasil Arnaudov

unread,
Apr 30, 2015, 3:14:08 AM4/30/15
to seleniu...@googlegroups.com


Hello,

I know that IE does not support user/pass injection but rather I would use WSH and internetexplorer.application for testing .
I'm trying with phantomjs (the browser I prefer because its easier to have headless browser) , chrome and firefox.
Appeared that chrome supports credential injection without any escaping!

But with firefox and phantomjs  nothing helps.And firefox is rather crucial for me.

Thanks.

Vasil Arnaudov

unread,
Apr 30, 2015, 4:04:29 AM4/30/15
to seleniu...@googlegroups.com

BTW
For firefox (I'm using Windows) when the browser is no headless as a workaround I'm starting following .bat file which will log me automatically when the login popup pops up:

::=====================================================
@if (@X)==(@Y) @end /* JScript comment
        @echo off
        mode 15,1
        rem :: the first argument is the script name as it will be used for proper help message
        cscript //E:JScript //nologo "%~f0" "%~nx0" %*
        exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */

var sh=new ActiveXObject("WScript.Shell");
for(;;){
        WScript.Sleep(3000);
       
        if (sh.AppActivate("Authentication Required")){
                sh.SendKeys("us...@com.com{TAB}password{ENTER}");
        }
} 
//::======================================================

Mukesh otwani

unread,
Apr 30, 2015, 8:45:42 AM4/30/15
to seleniu...@googlegroups.com
Hi Vasil,


userid and password passing directly in url does not work for me all the time.

I always use AutoIT to handle it. I have post for the same. Follow the procedure which i mentioned and let me know if you are facing any issue



On Wednesday, April 29, 2015 at 6:57:54 PM UTC+5:30, Vasil Arnaudov wrote:

Vasil Arnaudov

unread,
Apr 30, 2015, 3:43:48 PM4/30/15
to seleniu...@googlegroups.com
Thanks fr the reply,Probably I'll give up with handling the pop-up with pure selenium.Rather would use ,NET than external tools.Will post a solution with jscript.net (WScript.Shell is capable to handle Firefox and IE but not Opera and Chrome

Vasil Arnaudov

unread,
May 5, 2015, 5:23:12 AM5/5/15
to seleniu...@googlegroups.com


On Thursday, April 30, 2015 at 3:45:42 PM UTC+3, Mukesh otwani wrote:
Hi Vasil,


userid and password passing directly in url does not work for me all the time.

I always use AutoIT to handle it. I have post for the same. Follow the procedure which i mentioned and let me know if you are facing any issue




Hello,

I've checked your script and it is capable to handle only Firefox (for Opera and Chrome more advanced techniques are required to detect the login pop-up) .
But appActivate function is perfectly capable to do the same so there's no need of AutoIT. More over appActivate is capable also to handle the IE pop-up.
Another thing is your method only uses AutoIT recording so no parametrization is possible.


Here's my autologin script ->

with command line parameters or property file you can choose the browser (IE or Firefox), user and password and either or not to stop the script after the first login.
No additional tools are required it is just a bat file with embedded jscript code.I think its more convenient :-) .  

Reply all
Reply to author
Forward
0 new messages