installed xvfbwrapper python module.provided display start in python selenium test in MAC
from xvfbwrapper import Xvfb
class San(unittest.TestCase):
def setUp(self):
#display = Display(visible=0, size=(1480, 2000))
#display.start()
self.vdisplay = Xvfb(width=1480, height=2000)
self.vdisplay.start()
self.driver = webdriver.Chrome()
While running the test case , error occur
Traceback (most recent call last):
File "san98.py", line 34, in setUp
self.vdisplay.start()
File "/Library/Python/2.7/site-packages/xvfbwrapper.py", line 53, in start
stderr=open(os.devnull),
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
How to fix this issue
try this
sudo apt-get install xvfb
Related
from selenium import webdriver
browser = webdriver.Firefox(executable_path="/usr/bin/geckodriver")
browser.get('http://www.ubuntu.com/')
The entire stack trace looks like:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 160, in __init__
self.service.start()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'geckodriver'
my path to geckodriver is:
/usr/bin/geckodriver
And selenium is in:
selenium in /usr/local/lib/python3.6/dist-packages (3.12.0)
Thanks in advance!
You have most probably installed a version of geckodriver that is meant for a different OS/platform! get the correct version from https://github.com/mozilla/geckodriver/releases and replace the one you have.
Use this command to install the latest chrome driver which supports selenium:
sudo apt-get install chromium-chromedriver
Just created a fresh install of Ubuntu. Installed python and selenium, went to run this code:
#!/usr/bin/env python
from selenium import webdriver
browser = webdriver.Firefox('/usr/bin/')
browser.get('http://www.ubuntu.com/')
browser.close()
browser.quit()
when i run it, it just hangs in the terminal and then when I press Control-C it says:
^CTraceback (most recent call last):
File "test.py", line 5, in <module>
browser = webdriver.Firefox('/usr/bin/')
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 127, in __init__
firefox_profile = FirefoxProfile(firefox_profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 78, in __init__
ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
File "/usr/lib/python2.7/shutil.py", line 189, in copytree
copytree(srcname, dstname, symlinks, ignore)
File "/usr/lib/python2.7/shutil.py", line 189, in copytree
copytree(srcname, dstname, symlinks, ignore)
File "/usr/lib/python2.7/shutil.py", line 189, in copytree
copytree(srcname, dstname, symlinks, ignore)
File "/usr/lib/python2.7/shutil.py", line 192, in copytree
copy2(srcname, dstname)
File "/usr/lib/python2.7/shutil.py", line 130, in copy2
copyfile(src, dst)
File "/usr/lib/python2.7/shutil.py", line 84, in copyfile
copyfileobj(fsrc, fdst)
KeyboardInterrupt
If I don't kill the program and it fills my tmp folder for some reason.
I have tried installing selenium three different times across different VMs, using venv, moving selenium all of the place. I am LOST.
Any help is greatly appreciated!!
EDIT: I removed the '/usr/bin/' per #L3viathan and ran it. My new error is:
Traceback (most recent call last):
File "test.py", line 5, in <module>
browser = webdriver.Firefox()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
Couldn't make anything work anymore so I started up another fresh Ubuntu VM and have only done the following commands.
$ sudo apt-get install python-pip
$ sudo pip install selenium
And then I ran my program and got the geckodriver error. So I downloaded the geckodriver. and moved it to /usr/bin/
$ sudo cp geckodriver /usr/bin/
ran program and get EXACT same error:
Traceback (most recent call last):
File "test.py", line 5, in <module>
browser = webdriver.Firefox()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
The script is:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.python.org")
and this come out:
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/GeniusV/Documents/pythonProject/untitled/hj.py
Traceback (most recent call last):
File "/Users/GeniusV/Documents/pythonProject/untitled/hj.py", line 5, in <module>
driver = webdriver.Firefox()
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 103, in __init__
self.binary, timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 67, in launch_browser
self._start_from_profile_path(self.profile.path)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 90, in _start_from_profile_path
env=self._firefox_env)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
i really don't understand why,is it my python or selenium's problem?
Sounds like a compatibility issue.
Make sure you are using the latest selenium:
pip install --upgrade selenium
And have the latest Firefox installed.
So I'm trying to run Selenium on my raspberry pi using Chromium and for some reason I can't get my python file to compile. I keep getting the following error:
Traceback (most recent call last):
File "test.py", line 4, in <module>
driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver.exe'))
File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/service.py", line 75, in start
os.path.basename(self.path), docs_msg)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Here is the python code I'm trying to run:
from selenium import webdriver
import os
driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver'))
driver.get("http://www.google.com")
driver.quit()
Any ideas?
Update
After removing the '.exe' at the end of chromedriver, it now produces the following error:
Traceback (most recent call last):
File "test.py", line 4, in <module>
driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver'))
File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/service.py", line 68, in start
self.service_args, env=env, stdout=PIPE, stderr=PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
Ubuntu has builds of chromium-chromedriver as .deb files for armhf.
On launchpad, therefore, you can find chromium-chromedriver armhf builds available for download. Just download the latest version, and since they have no dependencies, you can install by running dpkg -i chromium-chromedriver_58.0.3029.96-0ubuntu0.14.04.1174_armhf.deb. Then chromedriver will be available in /usr/lib/chromium-browser/chromedriver.
At the moment Chrome Driver dont support ARM processors architecture anymore.
https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=95322
I'm trying to build jsoncpp's documentation (https://github.com/open-source-parsers/jsoncpp) in Ubuntu 14.10. As said in the github's README.md, I run the doxybuild.py script but I get the following error :
$> cd jsoncpp/
$> python doxybuild.py --doxygen=$(which doxygen) --open --with-dot
Deleting directory: dist/doxygen
Running: /home/jeremy/Projets/Perso/CmdSeries/libs/jsoncpp/doc/doxyfile
Traceback (most recent call last):
File "doxybuild.py", line 169, in <module>
main()
File "doxybuild.py", line 166, in main
build_doc( options )
File "doxybuild.py", line 116, in build_doc
ok = run_doxygen( options.doxygen_path, 'doc/doxyfile', 'doc', is_silent=options.silent )
File "doxybuild.py", line 67, in run_doxygen
process = subprocess.Popen( cmd )
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
$> sudo python doxybuild.py --doxygen=$(which doxygen) --open --with-dot
Deleting directory: dist/doxygen
Running: /home/jeremy/Projets/Perso/CmdSeries/libs/jsoncpp/doc/doxyfile
Traceback (most recent call last):
File "doxybuild.py", line 169, in <module>
main()
File "doxybuild.py", line 166, in main
build_doc( options )
File "doxybuild.py", line 116, in build_doc
ok = run_doxygen( options.doxygen_path, 'doc/doxyfile', 'doc', is_silent=options.silent )
File "doxybuild.py", line 67, in run_doxygen
process = subprocess.Popen( cmd )
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Does anyone have an idea ?
Already tried :
chmod u+x doxybuild.py
sudo chmod 775 /usr/lib/python2.7/subprocess.py
sudo chown $USER /usr/lib/python2.7/subprocess.py
But nothing resolved my problem.
Ok, problem solved :
$> cd jsoncpp/doc
$> cat readme.txt
The documentation is generated using doxygen (http://www.doxygen.org).
$> sudo apt-get install doxygen
...
OK
$> python doxybuild.py --doxygen=$(which doxygen) --open --with-dot
...
ok
Just install doxygen and building the documentation will work.