【文件属性】:
文件名称:已经创建了-origin9.0教程
文件大小:6.56MB
文件格式:PDF
更新时间:2021-06-29 20:21:20
selenium python
置超时时间。本书在第2章已经创建了
SearchProductTest测试类,是基于unittest写的测
试。我们将基于这个类进行修改,在setUp() 方法中
加入隐式等待时间并且设置为10秒,代码如下面的
例子所示。当一个测试用例执行的时候,
WebDirver在找不到一个元素的时候,将会等待10
秒。当达到10秒超时时间后,将会抛出一个
NoSuchElementException 的异常。
import unittest
from selenium import webdriver
class SearchProductTest(unittest.TestCase):
def setUp(self):
# create a new Firefox session
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.driver.maximize_window()
# navigate to the application home page
self.driver.get("http://demo.magentocommerce.com
/")
def test_search_by_category(self):
# get the search textbox