zoukankan      html  css  js  c++  java
  • 测试google搜索的代码

    #!/usr/bin/env python
    
    # Copyright 2012 splinter authors. All rights reserved.
    # Use of this source code is governed by a BSD-style
    # license that can be found in the LICENSE file.
    
    import unittest
    from splinter import Browser
    
    
    class TestGoogleSearch(unittest.TestCase):
        @classmethod
        def setUpClass(cls):
            cls.browser = Browser()
    
    
        @classmethod
        def tearDownClass(cls):
            cls.browser.quit()
    
    
        def test_visiting_google_com_returns_a_page_with_Google_in_title(self):
            self.browser.visit('http://www.google.com/')
            self.assertIn('Google', self.browser.title)
    
    
        def test_filling_Splinter_in_the_search_box_returns_Splinter_website(self):
            self.browser.visit('http://www.google.com.hk/')
            self.browser.fill('q', 'Splinter')
            search_button = self.browser.find_by_name('btnK').first
            while not search_button.visible:
                # waits for the JavaScript to put the button on the page
                pass
            search_button.click()
            self.assertTrue(self.browser.is_text_present('splinter.cobrateam.info'))
    
    
    unittest.main()
  • 相关阅读:
    系统手动激活
    scroll-into-view 简单demo
    css3 box-shadow 单边阴影
    js前端常用的方法
    css 箭头
    当前页面返回前一个页面时,执行前一个页面的方法
    小程序自定义组件
    vuejs2-生命周期
    Vuejs2-mock数据
    vuejs2+axios设置
  • 原文地址:https://www.cnblogs.com/hzhida/p/2634543.html
Copyright © 2011-2022 走看看