2011-11-30 109 views
5

我试图在Selenium上使用Snow Leopard中的Python(2.6.1)。是相当新的Python的,我是在为一点什么,我做错了,因为这完全一样的过程中损失的奋力在我的Ubuntu箱就好了:Snow Leopard上的硒和Python

  1. 须藤的easy_install -U硒
  2. 创建与Firefox硒UI一个简单的测试,并将其导出为Python中的webdriver(如mytest.py)
  3. $蟒蛇mytest.py(这会导致:

此错误消息:

E 

====================================================================== 
ERROR: test_mytest_py (__main__.MytestPy) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "mytest.py", line 8, in setUp 
    self.driver = webdriver.Firefox() 
    File "/Library/Python/2.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 45, in __init__ 
    self.binary, timeout), 
    File "/Library/Python/2.6/site-packages/selenium/webdriver/firefox/extension_connection.py", line 46, in __init__ 
    self.binary.launch_browser(self.profile) 
    File "/Library/Python/2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 41, in launch_browser 
    self._start_from_profile_path(self.profile.path) 
    File "/Library/Python/2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 66, in _start_from_profile_path 
    Popen([self._start_cmd, "-silent"], stdout=PIPE, stderr=PIPE).wait() 
    File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 595, in __init__ 
    File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1106, in _execute_child 
OSError: [Errno 2] No such file or directory 

---------------------------------------------------------------------- 
Ran 1 test in 0.302s 

FAILED (errors=1) 

有一两件事值得一提的是,当我跑“命令的easy_install -U硒”,我没有得到一个警告:

$ sudo easy_install -U selenium 
Searching for selenium 
Reading http://pypi.python.org/simple/selenium/ 
Reading http://www.openqa.org/ 
Reading http://code.google.com/p/selenium/ 
Reading http://seleniumhq.org/ 
Best match: selenium 2.14.0 
Downloading http://pypi.python.org/packages/source/s/selenium/selenium-2.14.0.tar.gz#md5=8de9ee26d699d699f846f14f9a184e60 
Processing selenium-2.14.0.tar.gz 
Running selenium-2.14.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-yQVlpa/selenium-2.14.0/egg-dist-tmp-svoAjf 
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'src_root' 
warning: no files found matching 'docs/api/py/index.rst' 
Adding selenium 2.14.0 to easy-install.pth file 

Installed /Library/Python/2.6/site-packages/selenium-2.14.0-py2.6.egg 
Processing dependencies for selenium 
Finished processing dependencies for selenium 
+0

你已经安装的XCode?如果没有,应该修复它 – pna

+0

@pna,我确实安装了XCode。 – rcourtna

回答

7

首先检查您的Firefox二进制位置。它放在这里:/Applications/Firefox.app/Contents/MacOS/firefox ?

欲了解更多信息,请查看此页:http://code.google.com/p/selenium/wiki/FirefoxDriver

+0

是的!我总是将我下载的应用程序放入应用程序/ -MyApps/...将Firefox移至应用程序根目录后,一切都按预期工作。谢谢! – rcourtna

+0

我已经将Firefox移动到/ Applications中的一个子目录中,一旦我将它移回来,错误已修复。谢谢! – velotron

0

我一无所知硒,但回溯表明,它没有一个可用Firefox的路径。

您将需要更改其配置/配置文件以为其提供可执行版本的Firefox路径。

该配置文件可能具有Firefox在Linux机器上的默认位置(因此它在Ubuntu上运行的原因)。但它不会在OSX上的这个位置。

+0

这可能是,但我会在哪里配置? – rcourtna