• RF05 Keywords


    目录

    一、*** Keywords ***介绍

            用户自定义的关键字定义在*** Keywords ***下。在RF中,可以按照PO编程的思想,把页面的元素封装进关键字中,方便用户在Test Cases中调用

    二、*** Keywords ***使用案例

    *** Keywords ***
    登陆 # 用户关键字
        [Arguments]    ${url}    ${username}    ${pwd}
        SeleniumLibrary.Open Browser    ${url}    chrome
        SeleniumLibrary.Wait Until Element Is Visible    ${用户名输入框}    
        SeleniumLibrary.Input Text    ${用户名输入框}    ${username}
        SeleniumLibrary.Input Text    ${密码输入框}    ${pwd}
        SeleniumLibrary.Click Element    ${登陆按钮} 
    

    三 常用关键字

    3.1 浏览器相关

    • open Browser
      • 参数说明
        • desired_capabilities
        • ignoreProtectedModeSettings=true
        • ignoreZoomSetting=true
    • Get Location
    • Get Location
    • Switch Browser
    • select window
      • 用于选择新窗口,参数可以是title、name或url,也可以是固定参数(如MAIN、CURRENT、NEW)以及Get Window Handles的返回值
    • Get Window Handles
    • Close Browser
    • Close All Browser
      • 关闭所有浏览器
    • GO BACK
    • GO TO
    • Maximize Browser Window
      • 页面最大化

    3.2 页面元素相关

    • click element
      • 尽量使用该关键字代替以下几个关键字,一般的locator包括:id、name、xpath、css等
    • Click Button
    • Click Image
      • srcalt
    • Click Link
      • hreflink text
    • Focus
      • 获取焦点
    • Double CLick Element
      • 双击元素
    • Input Text
    • Slect Frame
      • 注意该关键字的使用,如果元素在一个frame下,则必须使用该关键字,在定位元素
    • unselect Frame
      • 无参数,退出当前frame
    • Select From List
    • Select Checkbox
      • 选中,如果已选中则什么都不做
    • Get Element Attribute
    • Drag And Drop
      • 拖动元素
    • Get Matching Xpath Count
      • 获得符合Xpath的元素的个数,注意:此处xpath前缀不用写

    3.3 验证相关(检查点)

    • Element Should Be Visible
    • Element Should Not Be Visible
    • Page should containd element
    • Page should Not Contain ELement
    • Page Should Contain
    • ...

    3.4 等待相关

    • Wait For Condition
    • Wait Until Element Is Visible
    • Wait Until Page Contains
    • Wait Until Page Contains Element
    • Wait Until Page Does Not Contain
    • Wait Until Page Not Contain Element

    3.5 模拟鼠标键盘事件

    • Mouse Down
    • Mouse Down On Image
    • Mouse Down On Link
    • Mouse Out
    • Mouse Over
    • Press Key

    3.6 其他相关

    • Assign Id To Element
    • Capture Page ScreenShot
    • Execute Javascript
    • Get WebElements
    • Get WebElement
  • 相关阅读:
    OutputStream (字节流写出)
    Reader(字符流读取)
    InputStream (字节流读取)
    File
    IO简介
    BigDecimal
    SimpleDateFormat
    Date和Calendar
    包装类
    本地与远程对应分支,本地建立分支,修改代码, 上传到远程对应的分支
  • 原文地址:https://www.cnblogs.com/gupan/p/9538093.html
Copyright © 2020-2023  润新知