• Robot Framework 1


    about Robot, learnt from the following document, perfect document !!!!

    http://www.virtuousprogrammer.com/?s=robot

     
    Test Automation with Robot Framework
     
    Here's the content of the "SimpleTest.txt"
    *** Settings ***
    Library       Selenium Library
    
    *** Testcases ***
    Login Should Succeed When the Correct Username and Password are Entered
      Start Selenium Server
      Set Selenium Timeout  10
      Open Browser  file:///D:/robot/Login.htm  ie
      Sleep  3
      Input Allentext  uname  AUser
      Input Text  pwd    TestPass
      Click Button  login
      Page Should Contain  AUser
      Close Browser
      Stop Selenium Server

    打开 Ride, 看到的如下:

    所以你一定问, 这种浅蓝色的 low level keyword 到底是在哪里定义的?

    比如 Start Selenium Server:

    其实来源于:

    *** Settings ***
    Library       Selenium Library

    RIDE UI 上是:

    可只是一句 "Library Selenium Library" 就可以了么?到底 Selenium Library 在哪里?

    很简单: C:Python27Libsite-packages

    打开 __init__.py, 能够看到如下:

        def start_selenium_server(self, *params):
            """Starts the Selenium Server provided with SeleniumLibrary.
    
            `params` can contain additional command line options given to the
            Selenium Server. This keyword uses some command line options
            automatically:
    
            1) The port given in `importing` is added to `params` automatically
            using the `-port` option.
    
            2) A custom Firefox profile that is included with the library
            and contains automation friendly settings is enabled via the
            `-firefoxProfileTemplate` option. You can override this
            profile with your own custom profile by using the same argument
            in `params` yourself. To use the default profile on your machine,
            use this argument with `DEFAULT` value (case-sensitive).
    
            3) Starting from SeleniumLibrary 2.6, if there is `user-extensions.js`
            file in the same directory as Selenium Server jar, it is loaded using
            the `-userExtensions` option.  This is not done if the option is
            defined in `params`.  By default, such extension file providing Flex
            testing support is loaded automatically.
    
            Special syntax `JVM=some jvm opts` can be used to define options to
            the java command itself used to start the selenium server. This
            possibility was added in SeleniumLibrary 2.9.1.
    
            Examples:
            | Start Selenium Server | | | # Default settings. Uses the Firefox profile supplied with the library. |
            | Start Selenium Server | -firefoxProfileTemplate | C:\\the\\path | # Uses custom Firefox profile. |
            | Start Selenium Server | -firefoxProfileTemplate | DEFAULT | # Uses default Firefox profile on your machine. |
            | Start Selenium Server | -avoidProxy | -ensureCleanSession | # Uses various Selenium Server settings. |
            | Start Selenium Server | -JVM=-DserverName=somehost | # Define JVM options. |
    
            All Selenium Server output is written into `selenium_server_log.txt`
            file in the same directory as the Robot Framework log file.
    
            If the test execution round starts and stops Selenium Server multiple
            times, it is best to open the server to different port each time.
    
            *NOTE:* This keyword requires `subprocess` module which is available
            on Python/Jython 2.5 or newer.
            """
            params = ('-port', str(self._server_port)) + params
            logpath = os.path.join(self._get_log_dir(), 'selenium_server_log.txt')
            self._selenium_log = open(logpath, 'w')
            start_selenium_server(self._selenium_log, self._jar_path, *params)
            self._html('Selenium server log is written to <a href="file://%s">%s</a>.'
                       % (logpath.replace('\', '/'), logpath))

    这就是 start selenium server 的最源头。

    我们也可以把整个 C:Python27Libsite-packagesSeleniumLibrary 文件夹复制一份并且重命名为 "AllenLibrary", 然后打开  __init__.py, 把其中所有的 "SeleniumLibrary" 替换成 "AllenLibrary".

    这时就可以直接使用 AllenLibrary了。

    看,上面就是 Allen Library 的情况。

     我们可以使用多个 library。

    *** Settings ***
    Library           Selenium Library
    Library           Allen Library
    
    *** Test Cases ***
    testcase1
        AllenLibrary.Start Selenium Server
        AllenLibrary.Set Selenium Timeout    10
        SeleniumLibrary.Open Browser    file:///D:/robot/Login.htm    ie
        Sleep    3
        SeleniumLibrary.Input Allentext    uname    AUser
        SeleniumLibrary.Input Text    pwd    TestPass
        Comment    AllenLibrary.Input Allen2text    uname    BUser
        sleep    3
        AllenLibrary.Click Button    login
        AllenLibrary.Page Should Contain    AUser
        AllenLibrary.Close Browser
        AllenLibrary.Stop Selenium Server

     只是之后使用的时候要表明清楚所用的方法是从 AllenLibrary来的,还是从 SeleniumLibrary来的。

     
  • 相关阅读:
    算法沉思录之算法的结构
    OSSpinLockLock加锁机制,保证线程安全并且性能高
    iOS 开源库系列 Aspects核心源码分析---面向切面编程之疯狂的 Aspects
    代码阅读沉思录:代码的灵、肉与骨
    iOS AOP框架Aspects实现原理
    最近还是太浮躁了,一周阅读一个开源库是值得的
    performSelector 多参调用的实现方案
    oc消息转发:forwardInvocation、签名、参量个数、SEL 相关测试
    isa class superclass metaclass
    ARC与Toll-Free Bridging
  • 原文地址:https://www.cnblogs.com/backpacker/p/4156664.html
Copyright © 2020-2023  润新知