diff --git a/Readme.md b/Readme.md index eb5b098..454f63d 100644 --- a/Readme.md +++ b/Readme.md @@ -10,4 +10,5 @@ - 填入设备的chromwebdriver文件的全路径 运行命令: -pytest -v test/web_ut.py -o junit_family=xunit2 --junit-xml=pytests.xml \ No newline at end of file +pytest -v test/web_ut.py -o junit_family=xunit2 --junit-xml=pytests.xml +我在pycharm 中执行了脚本,脚本是正常通过的,但是通过jenkins 运行代码才报的找不到driver \ No newline at end of file diff --git a/iselenium.ini b/iselenium.ini index 6f69e4f..a0bf252 100644 --- a/iselenium.ini +++ b/iselenium.ini @@ -1,2 +1,2 @@ [driver] -chrome_driver= \ No newline at end of file +chrome_driver=C:\Users\lnz\chromedriver.exe \ No newline at end of file diff --git a/test/web_ut.py b/test/web_ut.py index aba3105..f79fa40 100644 --- a/test/web_ut.py +++ b/test/web_ut.py @@ -12,7 +12,7 @@ class ISelenium(unittest.TestCase): # 读入配置文件 def get_config(self): config = configparser.ConfigParser() - config.read(os.path.join(os.environ['HOME'], 'iselenium.ini')) + config.read(os.path.join(os.environ['HOMEDRIVE'],os.path.join(os.environ['HOMEPATH'], 'iselenium.ini'))) return config def tearDown(self): @@ -57,11 +57,11 @@ def _test_baidu(self, search_keyword, testcase_name): self.driver.get("https://ww.baidu.com") print('打开浏览器,访问 www.baidu.com') - time.sleep(5) + time.sleep(3) assert f'百度一下' in self.driver.title elem = self.driver.find_element_by_name("wd") elem.send_keys(f'{search_keyword}{Keys.RETURN}') print(f'搜索关键词~{search_keyword}') - time.sleep(5) + time.sleep(3) self.assertTrue(f'{search_keyword}' in self.driver.title, msg=f'{testcase_name}校验点 pass')