This question already has an answer here:
Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?
(1 answer)
Closed 2 years ago.
I have written a code to automate the login process by passing credentials in python and using selenium web driver. So, once the login is done, then the user will need to carry out some task and then he will be the one closing the browser, on closing the browser manually, is it possible to end the chromedriver process as well?
I dont think it is a good idea closing the browser manually. When you do it, you will get an Exception, maybe with message "timed out connecting to Chrome..." or something, because seleniumdriver instance is still running but chrome has gone.
I strongly suggest replacing this step by driver.quit.
BUT
If you really want to close the browser manually, maybe you can try to KILL the chromedriver process after that.
A demo in Java On Windows, like this:
Runtime.getRuntime().exec("taskkill /F /IM chromedriver.exe");
You don't need close manually , you can use close() method in selenium
driver.close();
The Close() method closes the currently open browser window, which has the WebDriver's focus. All other browser windows remain open, and the webdriver's instance remains open and usable too. The Quit() closes all browser windows, and further disposes of the WebDriver instance.
Related
I am using Firefox and the Selenium IDE plugin. I have a test for the login of my application. After the end of the test the browser stays logged in and the session gets reused. Can this be avoided ?
You need to invoke driver.quit() method within the tearDown() {}. Invoking quit() DELETEs the current browsing session through sending "quit" command with {"flags":["eForceQuit"]} and finally sends the GET request on /shutdown EndPoint.
References
You can find a couple of relevant detailed discussions in:
Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?
PhantomJS web driver stays in memory
This question already has an answer here:
Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?
(1 answer)
Closed 3 years ago.
I know using driver.quit() I can close all browser instances opened in a particular session. Now if my script has opened few browser instances in checking invalid login scenarios which remains opened, now if I run new script for valid login scenario and logout, this time I want my previously opened browser also to close when I use driver.quit()
But it's not happening, it is closing only browser opened in current session, not all those browser which was opened by selenium in older session. Is it possible to achieve my scenario? I heard about webDriver.Dispose() but I guess this is not applicable in current version of Selenium as it's showing error for me. Please suggest who I can achieve my scenario.
The current driver can only affect the windows opened by that driver. It sounds like in your invalid login script, you aren't using driver.quit() or the windows aren't getting closed properly. Once this happens, you can't use Selenium to fix it. You would need to use some sort of OS-based script to kill those open windows. For Windows, you can use a batch file that contains taskkill /f /im chromedriver.exe, etc. for each browser or a PowerShell script.
My web app uses IndexedDB and I'm testing on SauceLabs. Some months back my tests ran but now they block on a browser dialog that says "http://gbserver3.cs.unc.edu/" wants to: store files on this device", with an Allow button.
This is Win7 and Chrome or Firefox. Likely others too.
How can I dismiss or prevent this dialog?
Update: I have discovered that if I don't ask for quota I don't get the popup and my tests succeed. I'd still like to learn how to get rid of that dialog.
we are using Nightwatch.js in our project and we were facing the same issue.
What actually did the trick was using --unlimited-storage switch when launching the browser.
(List of other command line switches for Chromium can be found here)
I am working on client side. I have created around 150 test scripts. But during execution, after some script execution, Selenium throws below error and it close the browser. Time is not a fix for this error. It comes when I am executing all the test scripts together in parallel.
The error shows on Google Chrome and Firefox browsers. I am using selenium-server-standalone-2.26.0.jar file and doing execution on FF 13.0.1 version. I have also tried with FF version 14, but I get the same error. My client is not happy with this error because we dont have workaround for this issue.
**Error message:**
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Error communicating with the remote browser. It may have died
I think this will happen when you dealing with popup window.
Example
Working on main window clicking on something leads to open a new popup
switch the control to popup window & do your operations in pop-up
Most of the cases popup will be closed automatically after some action performed in it. (EX : Login with facebook option most of site now a days, after entering user credential no need to close that popup it will be closed automatically after submitting proper credentials)
After this you need to switch the control to main window again otherwise it will throws above exception.
I think your doing some operations without having the control over a window.
I am getting a warning like this when testing with selenium rc on IE Browser. Is there a command I can use to wait for it and click yes? Changing the Trusted Sites is not an option.
http://windowsxp.mvps.org/images/elevdialog.JPG
What we do is leverage a freely available tool called autoit which can interact with the windows component object model. If you are expecting the dialog you can invoke it with an exec and then proceed with selenium commands. If you want to catch unexpected ones, what we do is execute our selenium commands in a thread and if they time out we then run autoit having it return 0 or 1 depending if it finds a dialog and take things from there.
You are going to have to go into the IE Options and tweak the trusted sites so that it has those 2 sites. Once that has been done then you should be fine.