WebDriver Firefox profile not working after IEDriverServer setup - python

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

Related

FileNotFoundError: while converting .py to exe file

I'm trying to convert my py file to exe after when I run the exe file it always shows the same error on console windows
Traceback (most recent call last):
File "njlispendens.py", line 482, in <module>
File "selenium_stealth\__init__.py", line 45, in stealth
File "selenium_stealth\utils.py", line 8, in with_utils
File "pathlib.py", line 1132, in read_text
File "pathlib.py", line 1117, in open
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\alium\\AppData\\Local\\Temp\\_MEI93442\\selenium_stealth\\js\\utils.js'
[9744] Failed to execute script 'njlispendens' due to unhandled exception!
[10772:940:0102/104425.600:ERROR:chrome_browser_main_extra_parts_metrics.cc(226)] crbug.com/1216328: Checking Bluetooth availability started. Please report if there is no report that this ends.
[10772:6564:0102/104425.600:ERROR:device_event_log_impl.cc(214)] [10:44:25.611] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[10772:940:0102/104425.616:ERROR:chrome_browser_main_extra_parts_metrics.cc(229)] crbug.com/1216328: Checking Bluetooth availability ended.
[10772:940:0102/104425.616:ERROR:chrome_browser_main_extra_parts_metrics.cc(232)] crbug.com/1216328: Checking default browser status started. Please report if there is no report that this ends.
[10772:940:0102/104425.709:ERROR:chrome_browser_main_extra_parts_metrics.cc(236)] crbug.com/1216328: Checking default browser status ended.
Here is what I did to deal with the error
tried uninstalling packages and installing them again and then converting it into exe
tried Pyinstaller single and multiple file
adding python to path
tried using auto-py-to-exe to for conversion
tried uninstalling python, removing from path, installing python again
please help

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.

WebDriverException: Message: Can't load the profile. At a loss as to what is happening

I've been using webdriver.Firefox() for years now, today I started another project and browser = webdriver.Firefox() is returning
WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
I have tried adding C:\Program Files (x86)\Mozilla Firefox\firefox.exe to my PATH. I have tried pip install -U selenium. I've tried
binary = FirefoxBinary('C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe')
browser = webdriver.Firefox(firefox_binary=binary)
profile = FirefoxProfile("C:\Users\Me\AppData\Roaming\Mozilla\Firefox\Profiles\8u2w2ge1.Me")
browser = webdriver.Firefox(profile)
I have added the addon checkcompatibility to my firefox addons. Nothing, nothing is working, same error, Python 2.7.11, Windows 10 x64
This is the general traceback I am getting.
Traceback (most recent call last):
File "<pyshell#14>", line 1, in <module>
browser = webdriver.Firefox(firefox_binary=binary)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__
self.binary, timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable(timeout=timeout)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 108, in _wait_until_connectable
% (self.profile.path))
WebDriverException: Message: Can't load the profile. Profile Dir: c:\users\me\appdata\local\temp\tmpwvgny8 If you specified a log_file in the FirefoxBinary constructor, check it for details.
Anyone know why it is having issues creating this profile in the temp directory? Some new way to force it to profiles that exist, because my old method is not working.
I've actually found a work around for this, it isn't perfect and I actually use chrome through chromedriver, since it is a bit more stable, but to use firefox you might want to download a geckodriver and include it in your system path or path to it in your setup of the browser, https://github.com/mozilla/geckodriver/releases, seems to be where they keep releases, chrome has a chromedriver that functions and is used in much the same way. I am not sure why we need these new drivers to use selenium in windows, but such is life, hopes this saves someone else some work.

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

selenium fedora xfce amazon EC2

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

Categories