Forums

Newer version of selenium and Firefox?

Is there any way of using newer versions of Firefox, than default Firefox17 version in selenium. I've read something about some beta features, which enable that. Am I right activating these beta features on my account should help? If so, may I ask some admin to enable them? Thanks.

The Firefox that we have installed is the only one that is likely to work at the moment. You can use the Chrome that we have installed, though - that is more recent. Have a look at https://www.pythonanywhere.com/forums/topic/21948/#id_post_76488 for how to use it. I have enabled the feature for your account.

Huge thanks! :-)

Hi can I get chrome selenium feature enabled on my account also

No problem. I have enabled it for your account.

Thank you - do i need to simply reload my web instance or do I have to delete it and create a new instance to get it working?

I am still getting this error

Traceback (most recent call last): browser = webdriver.Chrome(options=chrome_options) TypeError: init() got an unexpected keyword argument 'options'

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)

NVM sorted I had to explicitly pip install on v3.8

OK, glad you worked it out!

Hello, I tried to get chrome headless running on my account but I get the error

'chromedriver' executable needs to be in PATH."

Is this because I haven't got the selenium feature enabled on my account?

It looks like it's because you're on an older version of our system image -- essentially, the operating system used for your account -- and that one doesn't have chromedriver installed. We can easily switch you over to a newer image -- all of your own files and data will be safe, it will just change the OS files. But one word of warning first -- because of the changes to the point releases of Python (eg. 3.7.0 to 3.7.5), any virtualenvs you have might break -- and if you're not using virtualenvs, the pre-installed Python modules will be upgraded so that might break any code you have that relies on the old installed versions.

Hi! Are you still manually giving accounts access to headless Chrome driver (I'm amazed at PA's responsiveness to these requests on the forum...)? Have just started going through Harry Percival's excellent TDD book and would love to follow along with Chrome (as I have several other use cases that require a new-ish Chromedriver). Thanks in advance. Kaan

On our EU systems, everyone now has access to Chrome :-)

All you need to do is upgrade Selenium for your account -- for example, if you're using Python 3.7, run this in Bash:

pip3.7 install --user --upgrade selenium

...and then you can run Selenium with Chrome using code like this:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)

try:
    browser.get("https://www.google.com")
    print("Page title was '{}'".format(browser.title))

finally:
    browser.quit()

Thanks Giles. I wonder what I'm doing wrong... I saved the above code to a script SeleniumRoutine.py. Just to double check I print sys.version and selenium.version at the top. The output from running $ python3.7 SeleniumRoutine.py is:

3.7.5 (default, Nov 14 2019, 22:26:37)  # sys version

[GCC 5.4.0 20160609] 3.141.0. # Selenium version Traceback (most recent call last): File "SeleniumRoutine.py", line 11, in <module> browser = webdriver.Chrome(options=chrome_options) File "/home/Kaan191/.local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init desired_capabilities=desired_capabilities) File "/home/Kaan191/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "/home/Kaan191/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/home/Kaan191/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/Kaan191/.local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 5.4.0-1029-aws x86_64)

If it helps... when I open a Python3.7 IDE terminal from my PythonAnywhere dashboard, the routine works fine.

When I SSH into my account (using Blink Shell on iPad) and open Python3.7 and run the commands line by line, confirming that I have the right version of selenium, it throws: selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

Will Chrome headless not work through SSH?

ah sorry! so for ssh and jupyter notebooks, the new virtualization stuff to get the newest Chrome is not supported yet. But anything you run from the console and from tasks or webapps etc would work.

Ok thanks!