Firefox won't 'drive' with Selenium webdriver - python

I've used Firefox with Webdriver on this machine before, but suddenly when I use any code that utilizes Firefox as the driver, Firefox will open and just sit there blankly. Absolutely nothing loads, my program hangs until I close the window at which point it raises the "browser not open" error.
Tried reinstalling. Chrome/IE Drivers work but I don't really want to use them.
Included a pic of exactly what happens when I use any code, for instance
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
url = "http://google.com"
driver.get(url)
Even this gets me nothing.

upgrade to selenium version 2.29.0
pip install -U selenium
there was a bug fix in the previous version

Related

My selenium script (in Python) for chrome runs but does nothing

vscode says it run but it does nothing. My pip is up to date and i installed selenium with the command prompt. i have a valid path (i think) for chromedriver. Here's my code:
from selenium import webdriver
chromedriver = "C:Users/P-Lou/Downloads/chromedriver.exe"
driver = webdriver.Chrome(chromedriver)
driver.get("http:google.com")
The result is this:
[Running] python -u "w:\Python\Seletest\app.py"
[Done] exited with code=0 in 0.067 seconds
I tried this code by only changing the browser to firefox and removing the chromedriver = part and it worked fine, you might be running the browser in headless mode, thats why nothing pops up. You can change that using The Chromedriver.options(set_headless="false")
(not sure if that is the right code, you can check yourself here)
Presuming the ChromeDriver binary location being C:\Users\P-Lou\Downloads on your windows system you can use the following solution:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'C:\Users\P-Lou\Downloads\chromedriver.exe')
driver.get("http:google.com")

using selenium without browser screen - python windows

i use selenium for instagram appicatin.
i wonder there is any way to run selenium without browser opening in windows?
there is some solution in linux like install Xvfb but i don't see any solution for windows!
Do you mean that --headless?
You can do some operations without opening Chrome if you have chrome-driver.
Here is how to set headless:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chromeoption = Options()
chromeoption.add_argument('--headless')
browser = webdriver.Chrome(options=chromeoption)
# Then it is your work.
browser.get(url="xxx")

Page is not loaded in Selenium WebDriver using Python on Windows

I am using Python 3.5 on a Windows computer. When I run this code on my Mac it works perfect, no issues what so ever. But when I bring the code to my Windows computer it doesn't work.
Basically a blank page is shown instead of the home page. I don't get any error messages.
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.google.com')
cookies = driver.get_cookies()
print(cookies)
Once I close the web browser I get this message in the shell:
"The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
From what I've been able to find online (most is for Java) it looks like I may need to setup a profile? Is this correct and could anyone help with this?
It looks like your client doesn't have the fix for the new switch to launch the gecko driver:
https://github.com/SeleniumHQ/selenium/commit/c76917839c868603c9ab494d8aa0e9d600515371
Make sure that you have the latest beta version installed (selenium-3.0.0b2) if you which to use the geckodriver v0.10.0 and above:
pip install -U selenium --pre
Note that you need the --pre flag to install the beta version.

Headless Selenium + Xvfb + Chrome on OSX 10.11

Okay, so first I learned that Xvfb wasn't included with my OS X version, so I installed it from http://www.xquartz.org/.
and that seemed to have worked:
which xvfb
/opt/X11/bin/xvfb
But when I try using it with either pyvirtualdisplay and xvfbwrapper, following advice I found on this question How do I run Selenium in Xvfb? My script runs without errors but just opens in a Chrome browser window:
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Chrome()
browser.get('google.com')
Am I doing something wrong here?
I believe that Chrome is built for Quartz ui framework, so it ignores the X11 windowing engine. You will need to install an X11 version of a browser and then execute that.
For me, this code works fine on OSX 10.13. You don't need pyvirtualdisplay, because you can run chrome in headless mode. Just download chromedriver that fits to your chrome version and put it to usr/local/bin
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--mute-audio')
options.add_argument('--lang=de')
options.add_argument('--window-size=800,600')
options.add_argument('--disable-notifications')
options.add_argument('--enable-popup-blocking')
browser = webdriver.Chrome(chrome_options=options, executable_path='/usr/local/bin/chromedriver')
browser.get('some url')

Why is Firefox's url address bar so small when Firefox is opened by Selenium?

I am trying to test a webpage with Selenium. My code is below.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("selenium")
elem.send_keys(Keys.RETURN)
driver.close()
When I run the above code, a Firefox browser window pops up as expected. However, the size of the window's fields are very small (see picture below). So small that the left most tab runs into the window's zoom button. This sizing issue does not occur when I use the Chrome WebDriver. Has anyone had this sizing issue? Any has anyone found out how to solve this issue?
Here is my mini-stack:
selenium 2.42.1 (installed via pip)
python 2.7.6
firefox 29.0.1
Mac OSX 10.9.3
This is the issue with the latest selenium package version:
Selenium launches FF with tiny font on OSX Macbook
As a workaround, downgrade selenium to 2.40.0 version:
pip install selenium==2.40.0

Categories