簡體   English   中英

Selenium和Python在雪豹

[英]Selenium and Python on Snow Leopard

我正在嘗試使用Selenium在Snow Leopard上使用股票Python(2.6.1)。 對於Python來說還是一個新手,對於我做錯的事情,我有點不知所措,因為這個完全相同的過程在我的ubuntu盒子上運行得很好:

  1. sudo easy_install -U selenium
  2. 使用Firefox Selenium UI創建一個簡單的測試,並將其導出為Python WebDriver(作為mytest.py)
  3. $ python 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)

值得注意的是,當我運行“sudo easy_install -U selenium”時,我確實收到了警告:

$ 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

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

有關詳細信息,請查看此頁面: http//code.google.com/p/selenium/wiki/FirefoxDriver

我對Selenium一無所知,但追溯表明它沒有可用的Firefox路徑。

您需要更改其配置/配置文件,以便為其提供可執行版Firefox的路徑。

現在的配置文件可能在Linux機器上具有Firefox的默認位置(因此它可以在Ubuntu上運行)。 但它不會在OSX上的這個位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM