zoukankan      html  css  js  c++  java
  • Selenium RC For Python:教程1

    Selenium是thoughtworks公司的一个集成测试的强大工具,关于它的好处网络随处可以搜到,我就不一一介绍,在之前见到一个系列是Selenium Remote Control For Java,在这里模仿一下,主要以Python来实现。一是我比较喜欢用Python,二是刚好可以练手,熟悉熟悉Python开发Selenium RC脚本。

    What is Selenium?
    Selenium is a testing tool for web applications that uses JavaScript and Iframes to run tests directly in a browser. There are several test tools based on this technology: Selenium Core, Selenium IDE, Selenium Remote Control, and Selenium on Rails. 

     下面的是第一个例子:

    在http://www.bitmotif.com/上点击link=Test Page For Selenium Remote Control,检查新页面的标题

    代码
    from selenium import selenium
    import unittest

    class ExampleTest(unittest.TestCase):
        MAX_WAIT_TIME_IN_MS 
    = 60000
        BASE_URL 
    = "http://www.bitmotif.com"
        
        
    def setUp(self):
            self.verificationErrors 
    = []     
            self.selenium 
    = selenium("localhost"4444"*firefox3 E:/Program Files/Mozilla Firefox/firefox.exe", self.BASE_URL)
            self.selenium.start()
            
        
    def tearDown(self):
            self.selenium.stop()
            
        
    def testClinckinglink(self):
            sel 
    = self.selenium
            sel.open(self.BASE_URL)
            sel.click(
    "link=Test Page For Selenium Remote Control")
            sel.wait_for_page_to_load(self.MAX_WAIT_TIME_IN_MS)
            expectedTitle 
    = u"Test Page For Selenium Remote Control « Bit Motif"
            
    #sel.get_title()
            self.assertEquals(expectedTitle, sel.get_title())
            
    if __name__ == '__main__':
        unittest.main()    


    作者:Shane
    出处:http://bluescorpio.cnblogs.com
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    TestNg JAVA 自动化单元测试框架Demo
    Python Unittest 自动化单元测试框架Demo
    Mac 安装工具包brew
    Mac 终端提示You have not agreed to the Xcode license agreements
    查看 ios 真机调试log,导出log
    Python WxPython 的安装以及使用
    RTMP协议抓包详解
    流媒体协议地址获取 rtmp
    手游-放开那三国socket协议分析
    jquery.tochart.js
  • 原文地址:https://www.cnblogs.com/bluescorpio/p/1741251.html
Copyright © 2011-2022 走看看