WebDriver - "Keep Me Logged In" - selenium-webdriver

I am testing an application that requires login. Using SafariDriver when I click the "Keep Me Logged In" button every new SafariDriver instance that is created is automatically logged in as expected; but when I use FirefoxDriver or ChromeDriver I am asked for my credentials every time as if I've never logged to the site using that browser before (when I have both manually and using webdriver). Is there some setting I need to enable so FireFox and Chrome keep me logged in?

This happens because WebDriver creates a new FireFox profile for every session. These profiles include caches/bookmarks/plugins etc. for more information refer to the documentation. FirefoxDirver allows you to start a FireFox with a specific profile. This can be done by using the following code:
FirefoxProfile ff = new FirefoxProfile(new File("/Path/to/profile/directory"));
driver = new FirefoxDriver(ff);
I'll update the answer if I find the way to do this in chrome

Related

Selenium webdriver add_cookies working but can't log in

Hello I'm using selenium and chrome driver to authomatically log in on amazon.jp and amazon.de.
I manually logged in on amazon.jp and checked the cookies
got cookies with get_cookies() and checked the list is okay
I opened the selenium driver and moved to amazon.jp and used add_cookies()
checked the cookies were added and it was same to what I got from "get_cookies()"
I moved to amazon.jp again and it seems that sign-in didn't work
The same process worked for taobao and other sites, so does Amazon uses some different ways(plus cookies) to log in?

Start a browser with a logged proxy in Robot framework

i'm facing the current problem: Since i'm under VPN, when i open a browser, a browser popup appears and ask me for the user and password credentials:
I need to open a browser in robot framework (firefox or chrome is the same) with a logged proxy.
I know that is possible to open a firefox instance with a proxy by using SeleniumLibrary Create Webdriver:
${proxy}= Evaluate selenium.webdriver.Proxy() modules=selenium, selenium.webdriver
${proxy.http_proxy}= Set Variable localhost:8888
Create Webdriver Firefox proxy=${proxy}
The problem is that it seems not possible to pass the credentials (user and password) for the proxy login.
Also, like most of the people suggest, i know that is possible to open the browser logged in with the proxy by using the url formatted like (in past i've also used that on different projects):
https://proxy_user:proxy_password#url_to_reach.com
but for some reason it doesn't work, i still have the browser popup asking me the credentials.
I've also tried by using Input Text Into Alert but it doesn't fill the alert fields:
Input Text Into Alert text=username action=LEAVE
I've also thought that maybe it is possible to do by using some preferencies with chrome or a profile with firefox but i've found nothing about this. Any other method by javascript?
Anyone can help? Thanks a lot

How to update Firefox WebExtensions deployed with Firefox in an enterprise environment?

I am distributing Firefox ESR in an enterprise environment, including a homemade WebExtension in the distribution\extension directory as explained in https://support.mozilla.org/en-US/kb/deploying-firefox-with-extensions
This instance of Firefox is installed to be used for a particular set of applications and is not intended to be used as the user's main browser. It is launched through a cmd script with a specific profile, for instance :
Firefox\browser\firefox.exe -profile myParticularProfile
Starting Firefox this way creates the profile if not already present, and the profile will not be visible in the profile manager.
Everything is fine after initial installation : every new profile of every user will get the extension copied to the extensions directory of its profile, and the extension is activated.
However, I need to be able to update the extension without reinstalling Firefox. The problem is, the updated extension does not get copied to existing profiles.
The documentation says that the extensions will be updated when Firefox is updated, but I need to be able to update the extension without updating/reinstalling Firefox.
Clearing the "extensions" folder in the profile does not solve the problem (the extension does not come back with the update version as I hoped)
I also tried clearing various cache directories without success
I hope I will not need to write a command script to update the extensions myself since I am not certain I will be able to easily locate and modify every user's profiles.
Maybe suggesting to firefox that it has been updated (even if it is not true) would do the trick, but I do not know if this is possible.
Any ideas ?

How to close browser (driver.quit / driver.close) and launch browser again in same test case in cucumber

I have to code scenario where with below cucumber steps
Scenario: Relaunched close browser
Given user launches the application
When user logs in with credentials
And user verifies logout button
And user closes the browser
And user opens browser and launches again
Then user should be taken to login page
we have #before hook written which initializes the browser and launch the application
but when I am closing the browser in middle of the test case then driver is lost. Now is there anyway I can call the #before hook post closing the browser ?
try using QAF where driver management done by QAF. You don't need to create driver. If you want to quite just do teardown it will automatically create new driver session when next time requested. Further more when you change driver.name property in code it will tear down current driver and create new requested driver.

IE 9 getWindowHandles - Does not identify new browser window

I am using Selenium 2.32, IEDriverServer 2.32, Eclipse, Java JDK 1.6.0_43 with Windows 7 and IE9. The code that i use to launch the driver is
File file = new File("IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(ieCapabilities);
In IE9, When i click on a link which opens a new browser, the driver.getWindowHandles() returns only one browser (Parent browser) and the new browser is never identified. When i use the same code with IE 8, it works and it identifies the new browser.
Due to company policy, the 'Security' settings are different for different zones in IE9. For two zones, the 'Enable Protected Mode' is enabled and while in other zones, the mode is not enabled. Is this the reason for the issue?. Please suggest.
Steps are as below:
'Enable Protected Mode' should be checked for all the zones and
security level should be set to "Medium".
Give some time to load the page using Thread.sleep(). Now you will
get correct value for getWindowHandles() method.

Resources