可怕
试试用 js
def test_executeScript(self):
url = 'http://www.baidu.com'
self.driver.get(url)
searfchInputBoxjs = 'document.getElementByid("kw").value=“测试数据”'
searfchButtonjs = 'document.getElementByid("su").click()'
try:
self.driver.execute_script(searfchInputBoxjs)
time.sleep(2)
self.driver.execute_script(searfchButtonjs)
time.sleep(2)
self.assertEqual('百度百科' in self.driver.page_source)
except WebDriverException as e:
print('没有找到元素')
except AssertionError as e:
print('页面不存在断言的关键字')
except Exception as e:
print(traceback.print_exc())