Bhavana
Bhavana

Reputation: 95

How to bypass authentication in selenium

I'm trying to automate a secure application(with useragent - iphone) which asks for authentication when i open the site. I tried giving the credentials in the URL itself to bypass the authentication but it pops up a dialogbox for confirmation which i'm unable to handle it through code.

FirefoxProfile profile = new FirefoxProfile();     
profile.setPreference("general.useragent.override",
    "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1"
    + "(KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3)"); 
WebDriver driver = new FirefoxDriver(profile); 
String site = "http://akamai:[email protected]";
driver.get(site);

Any help on this is highly appreciated.

Thanks, Bhavana

Upvotes: 0

Views: 8244

Answers (2)

Alberto
Alberto

Reputation: 5141

Mozilla blocks fishing attempts. Did you check Network.http.phishy-userpass-length?

By the way, according to Selenium's issue 34#8, this should work:

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.http.phishy-userpass-length", 255);
driver = new FirefoxDriver(profile);
driver.get("http://username:[email protected]/");

Note: this question is almost the same as BASIC Authentication in Selenium 2 - set up for FirefoxDriver, ChromeDriver and IEdriver.

Upvotes: 2

m4tt1mus
m4tt1mus

Reputation: 1641

You can use Selenium's new WebDriver to enter information into a dialog box of that type. However I haven't done it.

Upvotes: 0

Related Questions