Forums

Selenium WebDriverException error when saving screenshot.

I tried to take screenshot via selenium script as per your suggestion but iam getting a pythonanywhere error

Error is 'Access denied. Access to arbitrary websites is only available to Premium users.\nYou can sign up for a premium account at http://www.pythonanywhere.com/account/\nAlternatively, if you want to suggest something to add to our whitelist drop us a\nline at support@pythonanywhere.com'

Could you please enable selenium for me or add it to whitelist. Please help.

Hi Tomjoy,

I think the problem is not that Selenium is not enabled but that other people (not you!) have been using PythonAnywhere to do Denial of Service attacks on websites. And I don't think there is any way to enable only Selenium to 'see' websites, and not allow other parts of Python. (Come to mention it, I think you could probably do a DOS attack using Selenium if you were so minded.)

You might want to drop the developers an email and see if they will whitelist the sites you want to visit

Cheers, Robert

Yes, rcs1000 is exactly right. The message cited by tomjoy is what other non-premium users have been reporting since the addition of this change on PA. The PA folks have already said in other threads that if a site has a public facing API and provides a service that would be useful to other PA users that they are happy to add it to the white list. Unfortunately the site or sites you are trying to connect to must not be white listed at this point tomjoy.

All you will need to do is add the request to a post in this thread or email PA staff privately as rcs1000 has said.

Hey, thanks rcs1000 and a2j -- looks like the dev team might be able to stop answering stuff on the forums soon ;-)

Anyway, tomjoy took your advice and dropped us a line, so we'll see if we can sort out this one offline. As a2j says, we're happy to whitelist sites that have public APIs and provide a generally-useful service.

I tried this with whitelisted sites but getting the same access denied error.

The error is "Access denied. Access to arbitrary websites is only available to Premium users."

Source code

#importing selenium
from pyvirtualdisplay import Display
from selenium import webdriver

#initialize HIDDEN display
display = Display(visible=0, size=(800, 600))
display.start()

#initialize webdriver
browser = webdriver.Firefox()
browser.get('http://www.google.com')
browser.save_screenshot('...//screenie.png')
print browser.title
browser.quit() #important, or else loaded browser will remain running as a bg proc!
display.stop()

Please help .And give me a solution as soon as possible.Am struggling here.............

Congratulations! You have totally found a bug. You will need to add this to your script. Firefox is trying to send a request for localhost through to our proxy server.

import os
os.environ['no_proxy'] = '127.0.0.1'

We'll fix this in a general way as well so that it just works. But until we do you should use that bit of code to work around it.

Thanks..It executed sucessfully 2 times .

But now error varies......Please check..

Error 1

OSError at /pins/

[Errno 11] Resource temporarily unavailable

Request Method:     GET
Request URL:    http://tomjoy.pythonanywhere.com/pins/
Django Version:     1.3.1
Exception Type:     OSError
Exception Value:

[Errno 11] Resource temporarily unavailable

Exception Location:     /usr/lib/python2.6/subprocess.py in _execute_child, line 1051
Python Executable:  /usr/bin/python

Error 2.

WebDriverException at /pins/

Message: u'Component returned failure code: 0x8007000e (NS_ERROR_OUT_OF_MEMORY) [nsIWebNavigation.loadURI]'

Please help...

Hi tomjoy -- that looks like it's related to the issue we're discussing over email, perhaps it's fixed now?

Giles my spacing got decreased suddenly.....Please check.... Available 90% changes to 25% .....

Hi tomjoy, looks to me like you've got a lot of data in your /tmp folder?

You can check like this:

du -hs /tmp
du -hs /tmp/*

And remove stuff like this:

rm -rf /tmp/*

Hi, Thanks......I cleared the tmp data and tried selenium screenshot with white listed sites getting internal server error......

Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log. Apache/2.2.16 (Debian) Server at tomjoy.pythonanywhere.com Port 80

I noticed a whole bunch of dead firefox browser processes owned by you this morning. They may have been causing resource starvation for your account. I killed them because they weren't doing anyone any good. Be sure to close out any processes you create otherwise they may become orphaned and then you'll run out of resources.

Let me know if your app is behaving better now.

As am using selenium to take screenshot it will create automatically these firefox data.Any possibility to avoid these firefox creating temporary data code wise.Please advice ...

I don't know if you can stop Firefox from creating them, but perhaps you could put the code to delete them at the end of your process so that they don't accumulate over time?