Login popup window using selenium webdriver?

北城余情 提交于 2019-11-27 03:21:01

问题


the popup window is only happening if I use the Fire Fox browser otherwise, is there a way to fix this problem? I have to enter userid/password every time the i use FF as my browser.

currently, I am entering every time i run my test which is very painful but looking to make it more automated....

I have goggled and found two links here and here but no avail


回答1:


http://username:password@xyz.com 

This worked for me (xyz.com being the site name)




回答2:


After spending hours reading I finally found the solution which works pretty well and I hope this will help others too. - Enjoy!!

First - follow this steps:

1) Open the FireFox browser
2) Type the following `about:config`
3) Look for `network.http.phishy-userpass-length` if you don't find then create a new Integer key 
Create a new Integer key (right-click->New->Integer): `network.http.phishy-userpass-length` with value `255`

Second: You need to create a Firefox driver with the following:

FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "YOUR HOST ADDRESS HERE");
_driver = new FirefoxDriver(profile);

let me know if you have any questions.




回答3:


If this is a windows user account & password, then you need to enable the integrated windows login by setting

network.negotiate-auth.delegation-uris: MyIISServer.domain.com
network.automatic-ntlm-auth.trusted-uris: MyIISServer.domain.com
network.automatic-ntlm-auth.allow-proxies: True
network.negotiate-auth.allow-proxies: True

in the Firefox profile that WebDriver starts. Once you have the profile created and saved (run "Firefox -P" when no other instances are running to select a profile), you can do this in the code:

File profileDir = new File("C:/wherever/SeleniumFirefoxProfile");
FirefoxProfile profile = new FirefoxProfile(profileDir);
profile.setEnableNativeEvents(true);
driver = new FirefoxDriver(profile);



回答4:


I have had to handle these a few times, but my approach is using a script outside Selenium. Are you working on Windows?

Basically what you do is this:

1) Prior to loading the page, clicking the URL, etc that causes that dialog to appear:

-- Launch an asynchronous script to handle the login

2) Then load the page, click the link, etc

-- Selenium will block until your asynch script completes

The async script:

-- Sleep for a few seconds
-- Activate the dialog
-- Send the username
-- Send a TAB
-- Send the password
-- Send a TAB
-- Send the Enter Key

If you are working on windows, I can post sample scripts to handle this. I've done it with Java and C#, but I would guess that basically the same thing would work regardless of how you are writing your tests (unless you are strictly using the FF plugin, in which case this won't work).

Let me know if you'd like more details.




回答5:


You can use a FF plugin "autoauth". Download this plugin and create Firefox instance by the following way:

FirefoxProfile firefoxProfile = new ProfilesIni().getProfile("default");
File pluginAutoAuth = new File("D:\\autoauth-2.1-fx+fn.xpi");
firefoxProfile.addExtension(pluginAutoAuth);
driver = new FirefoxDriver(firefoxProfile);

I used "autoauth-2.1-fx+fn.xpi"



来源:https://stackoverflow.com/questions/12151958/login-popup-window-using-selenium-webdriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!