我已經在Python Selenium Webdriver中編寫了一些自動化測試。我正在閱讀Selenose
(http://shiningpanda.com/introducing-selenose.html) ,因爲我想嘗試將它用於我的測試用例,以使用1個Web瀏覽器的相同實例運行,而不是爲每個測試用例打開一個新的瀏覽器。Python Selenose啓用Selenium驅動程序插件顯示提供環境錯誤
我嘗試使用下面的命令從cmd以使硒驅動程序插件:
C:\Python27\Scripts>nosetests.exe --with-selenium-driver
我得到的錯誤:
File "C:\Python27\Scripts\nosetests-script.py", line 9, in <module>
load_entry_point('nose==1.3.7', 'console_scripts', 'nosetests')()
File "C:\Python27\lib\site-packages\nose-1.3.7-py2.7.egg\nose\core.py", line 1
21, in __init__
**extra_args)
File "C:\Python27\lib\unittest\main.py", line 94, in __init__
self.parseArgs(argv)
File "C:\Python27\lib\site-packages\nose-1.3.7-py2.7.egg\nose\core.py", line 1
45, in parseArgs
self.config.configure(argv, doc=self.usage())
File "C:\Python27\lib\site-packages\nose-1.3.7-py2.7.egg\nose\config.py", line
346, in configure
self.plugins.configure(options, self)
File "C:\Python27\lib\site-packages\nose-1.3.7-py2.7.egg\nose\plugins\manager.
py", line 284, in configure
cfg(options, config)
File "C:\Python27\lib\site-packages\nose-1.3.7-py2.7.egg\nose\plugins\manager.
py", line 99, in __call__
return self.call(*arg, **kw)
File "C:\Python27\lib\site-packages\nose-1.3.7-py2.7.egg\nose\plugins\manager.
py", line 167, in simple
result = meth(*arg, **kw)
File "C:\Python27\lib\site-packages\selenose-1.3-py2.7.egg\selenose\plugins.py
", line 78, in configure
raise ValueError('please provide a driver environment')
ValueError: please provide a driver environment
我創建了一個nose.cfg文件並將其保存在以下路徑:
C:\Python27\Lib\site-packages\nose-1.3.7-py2.7.egg\nose
nose.cfg
[selenium-driver:ie]
executable_path = C:\Webdriver\IEDriverServer\IEDriverServer.exe
webdriver = ie
[nosetests]
with-selenium-driver = true
我也從命令提示符
C:\Python27\Scripts>nosetests.exe --with-selenium-driver selenium-driver:ie
嘗試,我得到了同樣的錯誤。
我是否將nose.cfg文件存儲在錯誤的地方? 如何啓用Selenium驅動程序插件?
在我的測試用例類我從init方法調用self.driver,下面的代碼片段:
from selenose.cases import SeleniumTestCase
class AdministrationPage_TestCase(SeleniumTestCase):
def __init__(self):
self.driver.get(Globals.URL_riaz_pc)
self.login_page = login.LoginPage(self.driver)
self.driver.implicitly_wait(120)
self.driver.maximize_window()
我收到以下錯誤,當我運行命令:C:\ Python27 \腳本> nosetests.exe --with硒驅動--selenium驅動器=即 Ë 錯誤:pywin32_testall.run_test - --- Traceback(最近調用最後一次): 文件「C:\ Python27 \ lib \ site-packages \ nose-1.3.7-py2.7.egg \ nose \ case.py」,第1行 97,在的runTest self.test(* self.arg) 類型錯誤:RUN_TEST()至少需要1(給出0)參數 ---------- 冉1測試在0.012s FAILED(錯誤= 1) –
@RiazLadhani有趣,它爲我工作。 – alecxe
你在哪裏保存了你的nose.cfg文件,請問你的路徑是什麼? –