zoukankan      html  css  js  c++  java
  • Selenium WebDriver-通过断言页面是否存在某些关键字来确定页面按照预期加载

    #encoding=utf-8
    import unittest
    import time
    import chardet
    from selenium import webdriver
     
    class VisitSogouByIE(unittest.TestCase):
    
        def setUp(self):
            #启动IE浏览器
            #self.driver = webdriver.Firefox(executable_path = "e:\geckodriver")
            self.driver = webdriver.Ie(executable_path = "e:\IEDriverServer")
            
        def test_assertKeyWord(self):
            url = "http://www.baidu.com"
            # 访问百度首页
            self.driver.get(url)
            self.driver.find_element_by_id("kw").send_keys(u"光荣之路自动化测试")
            self.driver.find_element_by_id("su").click()
            time.sleep(4)
            # 通过断言页面是否存在某些关键字来确定页面按照预期加载
            assert u"首页--光荣之路" in self.driver.page_source, u"页面源码中不存在该关键字!"
    
    
    
        def tearDown(self):
            # 退出IE浏览器
            self.driver.quit()
    
    if __name__ == '__main__':
        unittest.main()
  • 相关阅读:
    (5)html表单
    (4)html表格
    (3)HTML ”列表“、图片和超链接
    (1)html开头解说与案例演示
    学习web前端前感
    一、资源合并与压缩
    HTTP协议原理
    图解HTTP总结
    基于TypeScript从零重构axios
    元組
  • 原文地址:https://www.cnblogs.com/qingqing-919/p/8709275.html
Copyright © 2011-2022 走看看