selenium fedora xfce amazon EC2 - python

I am running fedora 19 XFCE on EC2, I get this error when i run the python selenium script...
E
======================================================================
ERROR: test_PROG (__main__.TEST_PROG)
----------------------------------------------------------------------
Traceback (most recent call last):
File "selenium_asda.py", line 24, in setUp
self.driver = webdriver.Firefox()
File "/usr/lib/python2.7/site-packages/selenium-2.36.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 60, in __init__
self.binary, timeout),
File "/usr/lib/python2.7/site-packages/selenium-2.36.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/lib/python2.7/site-packages/selenium-2.36.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 61, in launch_browser
self._wait_until_connectable()
File "/usr/lib/python2.7/site-packages/selenium-2.36.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 100, in _wait_until_connectable
self._get_firefox_output())
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: \n(process:22490): GLib-CRITICAL **: g_slice_set_config: assertion `sys_page_size == 0\' failed\nGtk-Message: Failed to load module "canberra-gtk-module"\n*** LOG addons.xpi: startup\n*** LOG addons.xpi: checkForChanges\n*** LOG addons.xpi: No changes found\n/usr/lib/firefox/firefox: relocation error: /tmp/tmpxzNZAo/extensions/fxdriver#googlecode.com/platform/Linux_x86-gcc3/components/libwebdriver-firefox-latest.so: symbol _Znwj, version xul24.0 not defined in file libxul.so with link time reference\n'
----------------------------------------------------------------------
Ran 1 test in 5.193s
FAILED (errors=1)
the script works fine on my local machine...and I think this is related to the desktop settings for XFCE.
I connect to the instance via vnc and can get the full XFCE desktop with no issues.
Any hints?
SOLVED:
I downgraded selenium 2.36 to 2.35 and the tests runs OK.

That error is due to browser incompatibility. I had the same thing while trying to run FF24. Try the tutorial here to try and get it running with FF22.
Firefox browser issues with Selenium

Related

Unable to run Django Test Server in Ubuntu Server 16.04

I have 2 servers. I am attempting to setup one for continuous integration for my main website server
Web server 1(cloud-hosting):
Python3.6
Django3.1
Ubuntu16.04
Webserver 2(VPS):
Python3.7
Django3.1
Ubuntu16.04
Jenkins
--ShiningPanda(plugin)
Im new to web development, so if it seems odd as far as my web server types, that is why. I have been following along in the book Test Driven Development with Python. My issue is that when running python manage.py test [app] My [app] inherits from the class StaticLiveSever to generate a testing environment. On webserver 1, this works fine. On webserver 2, i get an error that the request address cannot be assigned. I use jenkins to build the environment, but the error i get is OSerror[99]:cannot assign requested address. I dont understand why this is happening when i run the same commands in Web Sever 1. It runs fine. Although again, the commands are run by jenkins and jenkins is configured to run python3.7
Full Traceback(Main Issue)
Traceback (most recent call last):
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/django/test/testcases.py", line 1449, in setUpClass
raise cls.server_thread.error
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/django/test/testcases.py", line 1374, in run
self.httpd = self._create_server()
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/django/test/testcases.py", line 1389, in _create_server
return ThreadedWSGIServer((self.host, self.port), QuietWSGIRequestHandler, allow_reuse_address=False)
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 67, in __init__
super().__init__(*args, **kwargs)
File "/usr/lib/python3.7/socketserver.py", line 452, in __init__
self.server_bind()
File "/usr/lib/python3.7/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.7/http/server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.7/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 99] Cannot assign requested address
After hardcoded host
Traceback (most recent call last):
File "/var/lib/jenkins/workspace/Superlists/functional_tests/base.py", line 47, in setUp
self.browser = webdriver.Firefox()
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 100, in start
self.assert_process_still_running()
File "/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 113, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 69
geckodriver.log w/ hardcoded host ip in LiveTestServer
eckodriver: error: Address not available (os error 99)
geckodriver 0.27.0 (7b8c4f32cdde 2020-07-28 18:16 +0000)
WebDriver implementation for Firefox
USAGE:
geckodriver [FLAGS] [OPTIONS]
[...]
Hopefully the tracebacks above are not too confusing. Ultmiately what i did notice was the when im in webserver 2, i access the Django testcases.py module that has LiverServerThread and hardcode host=0.0.0.0 instead of host=localhost (1st traceback). The connection is then made although then the problem lies with geckodriver and the same thing (2nd traceback). I need to hard code ip 0.0.0.0 to be able to establish a connection, but then geckodriver is just listening, which i am assuming, at a completely different location (no error.log shown here).
So 1st id like to at least be able to make a connection to run the LiveServerThread class properly. Then try and resolve the issue with geckodriver. I also was not sure if the type of servers im running on poses as the problem.

PhantomJS webdriver error code -6

I am running a Python script on a remote server that scrapes periodically a webpage, using PhantomJS as a webdriver in Selenium.
The script stops unexpectedly after running for some hours, throwing the following error:
Traceback (most recent call last):
File "long.py", line 74, in <module>
data = scrape_page_long()
File "long.py", line 19, in scrape_page_long
driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 96, in start
self.assert_process_still_running()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service phantomjs unexpectedly exited. Status code was: -6
I thought at first it had to do with ssl errors (hence the arguments), but it doesn't seem related I think.
Any ideas on what causes this issue?
Your script is never able to scrape the web page, because PhantomJS is not working at all on the server.
If you log into the server and run phantomjs --version you'll see this:
QXcbConnection: Could not connect to display
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
Aborted
You can fix this by adding export QT_QPA_PLATFORM=offscreen to your user account's .bashrc, or by adding QT_QPA_PLATFORM=offscreen to the server's /etc/environment.

selenium and web2py from killer-web-development.com doesn't work

I am trying to follow the tutorial on http://killer-web-development.com/section/4/3
and I am running into the error message:
======================================================================
ERROR: setUpClass (test_static_pages.TestHomePage)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Applications/web2py.app/Contents/Resources/applications/tukker/functional_tests.py", line 18, in setUpClass
self.browser = webdriver.Firefox()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 51, in __init__
self.binary, timeout),
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 46, in __init__
self.binary.launch_browser(self.profile)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
self._wait_until_connectable()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 86, in _wait_until_connectable
self.profile.path, self._get_firefox_output()))
WebDriverException: Message: 'Can\'t load the profile. Profile Dir: /tmp/tmpXWOMML Firefox output: 1409783847270\taddons.manager\tDEBUG\tLoaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]\n1409783847271\taddons.manager\tDEBUG\tLoaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]\n1409783847272\taddons.xpi\tDEBUG\tstartup\n1409783847273\taddons.xpi\tDEBUG\tSkipping unavailable install location app-system-share\n1409783847283\taddons.xpi\tDEBUG\tcheckForChanges\n1409783847286\taddons.xpi\tDEBUG\tNo changes found\nJavaScript error: chrome://browser/content/urlbarBindings.xml, line 674: aUrl is undefined\n'
What is wrong? I am on MacOsX maverics and have installed selenium using macports if that is of any help.
The reason you have problems is because you have a brand new browser and an old selenium.
You need to do two things:
upgrade selenium package to the latest (currently 2.42.1) version
downgrade Firefox to 28 version

WebDriver Firefox profile not working after IEDriverServer setup

I've been using webdriver.Firefox() for my test cases, but wanted to test on IE. I downloaded IEDriverServer, added it to my PATH and ran the IE test case successfully. However, when I then tried switching back to Firefox and running the same test case, the Firefox browser opened up, but nothing happened, and then I received this error:
C:\Python33\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py:85:
ResourceWarning: unclosed <socket.socket object, fd=280, family=2, type=1, proto=0>
while not utils.is_connectable(self.profile.port):
C:\Python33\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py:85:
ResourceWarning: unclosed <socket.socket object, fd=532, family=2, type=1, proto=0>
while not utils.is_connectable(self.profile.port):
E
======================================================================
ERROR: test_ytest (__main__.Ytest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\K\workspace\PythonTesting\src\RecipeTest.py", line 11, in setUp
self.driver = webdriver.Firefox()
File "C:\Python33\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 61, in __init__
self.binary, timeout),
File "C:\Python33\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "C:\Python33\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 51, in launch_browser
self._wait_until_connectable()
File "C:\Python33\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 95, in _wait_until_connectable
self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: "Can't load the profile. Profile Dir: c:\\users\\k\\appdata\\local\\temp\\tmp0vf9hl Firefox output: b'*** LOG addons.xpi: startup\\r\\n*** LOG addons.xpi: Skipping unavailable install location app-system-local\\r\\n*** LOG addons.xpi: Skipping unavailable install location app-system-share\\r\\n*** WARN addons.xpi: Ignoring missing add-on in C:\\\\Program Files (x86)\\\\Wajam\\\\Firefox\\\\{5a95a9e0-59dd-4314-bd84-4d18ca83a0e2}.xpi\\r\\n*** LOG addons.xpi: checkForChanges\\r\\n*** LOG addons.xpi: No changes found\\r\\n'"
----------------------------------------------------------------------
Ran 1 test in 35.208s
FAILED (errors=1)
I've removed the PATH to IEDriverSetup and went so far as to remove it. I restarted Eclipse (I'm using it to run my Python/WebDriver tests) and restarted IE and Firefox to no avail.
Any help is appreciated.
EDIT
I am using Python 3.3 to develop my test cases, if that makes a difference.
Is there a __pycache__ directory among your files?
I removed it. No error once it is removed.
PS. python 3.3.2

Instance of Firefox WebDriver is not created with selenium python bindings

I installed selenium-python bindings and trying to create an instance of firefox web driver
as below
>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
I dont know whats wrong here and its displaying the following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 51, in __init__
self.binary, timeout),
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
self._wait_until_connectable()
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 81, in _wait_until_connectable
self._get_firefox_output())
selenium.common.exceptions.WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: cannot open display: :1100\n'
Can any please let me know how to solve this ..............
The error says"cannot open display: :1100". Are you running it on a remote terminal? Make sure you can type "firefox" at the prompt and have the browser open (that is what Webdriver does - opens Firefox on your system and then trying to connect to it). If you are running it on a remote system, do a web search on connecting to X display remotely.

Categories