class Test():
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.driver.maximize_window()
self.driver.implicitly_wait(3)
# self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_sougou(self):
# 打开网页,设置窗口
self.driver.get("https://www.sogou.com/")
self.driver.set_window_size(1235, 693)
# 输入搜索信息
# self.driver.find_element(By.ID, "query").click()
self.driver.find_element(By.ID, "query").send_keys("霍格沃兹测试开发")
# 点击搜索
self.driver.find_element(By.ID, "stb").click()
# element = self.driver.find_element(By.ID, "stb")
# actions = ActionChains(self.driver)
# actions.move_to_element(element).perform()
time.sleep(5)
# 添加断言
fond_element = self.driver.find_element(By.ID, "sogou_vr_30000000_0")
assert "霍格沃兹测试开发" in fond_element.text
评论