jenkins里跑selenium webdriver,firefox浏览器不能打开
jenkins版本: 1.598
selenium版本: 1.42.2
firefox版本: 2.7
系统: windows2008 and windows2003
webtest.py
from selenium import webdriver
class Webtest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
...
我在windows的cmd里面执行 "python webtest.py",毫无问题,浏览器正常打开,测试结果也正常。
d:\python webtest.py
.
--------------------------------------------------
Ran 1 test in 42.978s
OK
但如果是在jenkins里,选择 "execute windows batch command",配置 "python webtest.py"跑测试,这时候就会有问题,firefox浏览器并不会打开,但是后台有进程,webtest会在后台运行,但运行起来总是会有点问题,例如
File "C:\Python27\lib\site-packages\selenium-2.42.1-py2.7.egg\selenium\webdriver\remote\webelement.py", line 370, in _execute
return self._parent.execute(command, params)
File "C:\Python27\lib\site-packages\selenium-2.42.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 173, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium-2.42.1-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
StaleElementReferenceException: Message: u'Element not found in the cache - perhaps the page has changed since it was looked up' ;
but,webtest.py in windows cmd executed is successed.
但webtest.py在cmd里直接执行是没有问题的。
所以不知道是什么问题?是版本问题还是什么?怎么才能让浏览器打开?
正义的米疙瘩
10 years, 4 months ago