Forums

Selenium

Which selenium browsers are supported. I have tried chrome, firefox, the standard HtmlUnit both with and without JS, and even IE and none have worked. It seems that even though selenium is technically supported, there aren't any usable browsers. Is this the case?

That's because there is a bit of a trick to using it headless

# Start up an Xvfb display
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()

# Load a Firefox selenium webdriver session
from selenium import webdriver
browser = webdriver.Firefox()

# Visit our front page
browser.get("http://www.pythonanywhere.com")
print browser.page_source
browser.close()

If you could always remember to wrap the entire block of code with a try: <code> finally: browser.close() that would be much appreciated. Otherwise we will have to go around cleaning up all the excess Firefoxes.

It's pretty freaking cool though. All thanks to Harry for getting really excited about it and making us install it.

Awesome, Thanks a lot for the response.

Does Selenium or Firefox create any cache files that need cleaning up? I seem to have used up a couple hundred Mbs of quota after some testing...

Yes actually Firefox does. have a look in /tmp. You'll see them all there.

Sorry, but I saw this thread only after starting to play around with Selenium. Therefore I didn't wrap the Firefox call in a try: to prevent spills. Is there a way I can clean up after my own /tmp files? I get "Cannot remove.....Device or resource busy" errors when I try to delete the files.

Solved. Seems that closing/reopening the shell took care of the "resource busy" issue.

And what about Chrome webdriver? how can i use chrome webdriver? is it possible to install it?

Hello adfox. Yes it should be possible. At the moment only firefox is supported though. I would have thought with your username though you would lean more towards the 'fox :)

@adfox: Welcome to the PA community. I trust you'll have a great time here. Be sure to ask any questions you need answered. The staff (and community) is highly responsive!!

I'm here. for solutions to my problem should at least add chromedriver https://code.google.com/p/chromedriver/downloads/detail?name=chromedriver2_linux64_0.5.zip&can=2&q= in / bin

and Chrome binary of course

and one more question, can you give me access to external domains for week for free?

Hi Adfox, we can look at installing Chrome (probably chromium actually, and the chromedriver executable) but it won't be something that happens over night. If you want to email support@pythonanywhere.com with the other request then we might be able to help. I've typically done it in the past to help people work through troubleshooting something. Basically so they could see whether something would work before upgrading their account.

@hansel , Is there a way to check and kill extra processes that may be running from selenium browsers left unclosed? I've put the commands in a try: finally: statement but there are cases where the browser leaves running processes. Thanks!

That's odd, we've not seen that before. Are you doing both browser.quit() and display.stop()?

Hi, this is an old thread... I am looking for help using chrome webdriver instead of firefox as the selenium browser. Has there been any update on this topic? Thanks

Thanks for reminding us! I think we let this slip off the radar. But it shouldn't be too hard to do, I'll see if I can get it bumped up the priority list. Will keep you posted (might be a few weeks til we can get a new server image build tested and out tho)

Hello, i tried your solution above , and i getthis error message: ImportError: no module named pyvirtualdisplay

hi there,

If you are just using our basic consoles, you should be able to import pyvirtualdisplay. However, if you have setup your own virtualenv, be sure to also install pyvirtualdisplay into your virtualenv.

Hello, I wonder if you could give an update on the Chrome driver for Selenium question please? I'm guessing it didn't hit the top of the priority list yet? Thanks.

Hi there, I'm afraid you're right, it's not something we've been able to schedule yet.

You might have some luck if you try to download and install (or compile if necessary) your own copy of chromium, and chromedriver?

Thanks for letting me know. In all honesty getting Chrome running is not top of my priority queue just yet. Firefox will do for the moment.

If I do have a chance to have a go with the Chrome driver install I'll post here. Don't hold your breath!

Has there been any progress yet with chromium/google chrome for selenium?

Sorry, no we haven't installed google chrome for selenium yet. I believe there is some incompatibility issue that we are dealing with but will double check.

Up Up Up ! Interested in the Chrome driver to work with Selenium ... :) If it can help to push it up on the priority list ! ;)

Noted

Chrome would be aweomse

Upvoted :-)

+1

Upvoted!

One more for Chrome driver!!

We want bread and chromedriver! :)

:-D

Upvoted. It's not going to be super-easy to add -- Chrome needs a number of changes to our virtualization system -- but it's definitely on the list. It would also make running Java code possible, which I guess is a bonus or a negative, depending on what you think about Java...

I do see your point; the problem that I am facing atm is that several websites I want to scrap cannot be opened with the method described above (do not support this firefox version). :(

Hi everyone, I haven't tried this myself, but it might be the case that our new sandboxing engine for the beta always-on tasks feature might support Chrome/chromedriver and newer Firefoxen/geckodriver.

Ping us a note here or by email and we'll switch it on for you if you want to give it a go?

You'll need to figure out how to download firefox and chromedriver binaries into your home folder, and how to tell selenium to use those binaries instead of the system-installed ones, but you might have a chance... Hey even phantomjs might work!

my own initial tests with PhantomJS are positive:

browser = webdriver.PhantomJS(executable_path='/home/harry/nvm/versions/node/v8.4.0/bin/phantomjs')

that definitely doesn't work in normal consoles/tasks, but it does in an always-on task...