1 Star 0 Fork 0

wtsnwei / learning-selenium-with-python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test_navigation.py 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
wtsnwei 提交于 2021-01-11 10:01 . first commit
import unittestfrom selenium import webdriverfrom selenium.webdriver.support import expected_conditionsfrom selenium.webdriver.support.wait import WebDriverWaitclass NavigationTest(unittest.TestCase): def setUp(self): options = webdriver.FirefoxOptions() options.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/69.0.3497.100 Safari/537.36"') self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.driver.maximize_window() # navigate to the application home page self.driver.get("http://duckduckgo.com/") def tearDown(self): self.driver.quit() def test_browser_navigation(self): driver = self.driver # get the search textbox search_field = self.driver.find_element_by_name("q") search_field.clear() # enter search keyword and submit search_field.send_keys("selenium") search_field.submit() se_wd_link = driver.find_element_by_link_text("Selenium") se_wd_link.click() self.assertEqual("SeleniumHQ Browser Automation", driver.title) driver.back() self.assertTrue( WebDriverWait(self.driver, 10).until( expected_conditions.title_is("selenium at DuckDuckGo") ) ) driver.forward() self.assertTrue( WebDriverWait(self.driver, 10).until( expected_conditions.title_is("SeleniumHQ Browser Automation") ) ) driver.refresh() self.assertTrue( WebDriverWait(self.driver, 10).until( expected_conditions.title_is("SeleniumHQ Browser Automation") ) )if __name__ == "__main__": unittest.main()
Python
1
https://gitee.com/wtsnwei/learning-selenium-with-python.git
git@gitee.com:wtsnwei/learning-selenium-with-python.git
wtsnwei
learning-selenium-with-python
learning-selenium-with-python
master

搜索帮助