I use Selenium to do the web-scraping. However, my Firefox browser always crashes after a while (it is very intensive the task of scraping).
The error message from Firefox:
Firefox had a problem and crashed. We’ll try to restore your tabs and
windows when it restarts.
The error message from Python:
selenium.common.exceptions.WebDriverException: Message: Tried to run
command without establishing a connection
I'd like to know if there's a way to deal with that. Ideally, I want something like after Firefox crashes, Selenium would open a new tab and continue from where it crashed.
i tried try: except:pass this type of code and they didn't work out.
Related
I'm running a Selenium webscraper in Java on a Linux server through SSH, but the browser crashes upon termination of the session despite various attempts to instruct the program to run in the background. Specifically, I've used screen, tmux, nohup, disown, and setsid (as here https://www.tecmint.com/keep-remote-ssh-sessions-running-after-disconnection/) with similar, bad results. I would like to try a VNC session, but so far not enabled on the server.
With screen for example:
I type screen, run the program, and normal output is produced
I detach the screen with Ctrl+a+d, normal output continues to be produced
I end the SSH session. Output ceases and (upon logging back in and returning to the screen session), I get the error message
Exiting due to channel error
Exiting due to channel error
Exiting due to channel error
Exiting due to channel error
Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to decode response from marionette
I've tried this a couple of times, so it's not a coincidence that it crashes at the exact time of ending the SSH session. What could be going wrong and how can I try to diagnose the issue?
System information:
OS: Red Hat Enterprise Linux, Linux 3.10.0-1127.10.1.el7.x86_64
Java: 1.8.0_252
Firefox version: Mozilla Firefox 78.3.1esr
Firefox boot options: "--marionette" "-headless" "-foreground" "-no-remote" "-profile"
Gecko driver version: 0.27.0
Selenium version: 3.141.59m revision e82be7d358
SSH client: MobaXTerm, personal version 10.4
Through sheer dumb trial and error luck I tried swapping MobaXTerm for PuTTY (continuing to use screen) and the problem went away. I have no idea why this works. The universe is a complex place which surpasses mere human comprehension.
I am doing selenium program and have written the script for Firefox browser. When I run the test, it opens a browser, but nothing happens after that. Console has below error:
"Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure."
What is the solution for this?
I am using code as :-
System.setProperty("webdriver.firefox.marionette","C:\\geckodriver-v0.18.0-win32\\geckodriver.exe");
Update your selenium jars and geckodriver. Update your firefox browser too.
This problem is happening when the jars are too old to handle new changes in browser.
Downlaod selenium jars :-
http://www.seleniumhq.org/download/
Download geckodriver :-
https://github.com/mozilla/geckodriver/releases
You are using wrong gecko parameter :-
System.setProperty("webdriver.gecko.driver","C:\\geckodriver-v0.18.0-win32\\geckodriver.exe");
Hope it will help you :)
We started a new Selenium environment with Selenium 3.4, using a grid configuration with a Linux-based hub and a Windows Server-based node. InternetExplorerDriver started throwing NoSuchWindowException when run remotely. I got the following output:
org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.xpath: //h2[starts-with(#class, 'headline')])
org.openqa.selenium.NoSuchWindowException: Unable to find elements on closed window (WARNING: The server did not provide any stacktrace information)
[many more stack trace lines]
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:141)
... 43 more
Ultimately it repeats the NoSuchWindowException over and over afterward.
We're running IE 11, so I ensured that Enhanced Protected Mode was disabled, the proper registry key fixes had been applied, and so on as described at SeleniumHQ (https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration), as well as many answers here on StackOverflow. Chrome works fine, Firefox works fine, IE even works fine as long as it is run locally. I can't find any more information on this.
How do I stop this exception from occurring?
For us, it was a matter of the Windows Server running the node (we had been running it on a Windows 7 machine previously). The node had to be run as an administrator. We ultimately created a shortcut and set it to be run as an administrator through the Shortcut tab -> Advanced button.
I am trying to inspect the page during an integration test, and so I have a test which I added a breakpoint in-- Once chrome launches and the test begins, the breakpoint hits, and the browser is idle.. As soon as I open the web inspector, chrome quits with the error:
Selenium::WebDriver::Error::WebDriverError:
disconnected: received Inspector.detached event
I am using Chrome version 37.0.2062.124, and ChromeDriver version 2.10.267517
This is intended. This is because the ChromeDriver uses the DevTools API to interact with Chrome.
The DevTools within Chrome has one major disadvantage and that is it only allows one debugger (whatever that might be, whether it's you or the driver itself) attached to it. Thus, once you open it, ChromeDriver cannot use it.
This is a limitation of Chrome -> the best you can do is get your test to a point where it fails, have your test close it's session but leave the browser open. Thus you have quit your test but effectively left your browser in the state of which the test failed.
This is about chrome issue(https://bugs.chromium.org/p/chromedriver/issues/detail?id=1194).
When you are running selenium program, you cannot press F12 to open dev tools manually, or it'll throw this exception sometimes.
According to the issue list, it looks like fixed, but I still meet this bug in ChromeDriver 2.29
The same problem you can visit.
I have a local selenium server (2.42.2) running with Chromedriver and Firefox. It seems to get stuck after loading and running client.html. I can see that my functional suite code runs in node, far enough to execute the main body. Anything in registerSuite never gets called.
Here are the selenium logs:
http://pastebin.com/KKg5ycvW
I can see the browsers in the selenium sessions page, but they don't appear to be doing anything.
Try opening up a new browser window and paste in the url that you see in the existing selenium ones. Then open up dev tools and see what console errors you are getting.
Intern's runner seems to get stuck in an infinite loop if any uncaught javascript errors are thrown during unit tests if the 'reporter' hasn't been setup yet.
This has been raised as an issue in intern's github repository.