*** Settings ***
Documentation                       此文件是一个包含可重用的关键字和变量的全局资源文件。
Library                             Selenium2Library
Library                             String
Library                             Collections
Library                             Tools.py
Library                             Handle.py
Library                             Generate.py
Library                             DateTime
*** Variables ***
################################## URL #########################################################
${URL_HOST}                         http://prerelease.journal-test.gdqhd.cn/#
${LOGIN_URL}                        ${URL_HOST}/login
${AFTER_LOGIN_URL}                  ${URL_HOST}/app/index.html
######################### 用户和浏览器设置 #####################################################
${BROWSER}                          Chrome
${DELAY}                            0
# ${VALID_USER}                       autotest
# ${VALID_PASSWORD}                   73Uw5Z
${VALID_USER}                       yw
${VALID_PASSWORD}                   1
${VALID_USERNAME}                   自动测试
######################### 全局变量 #################################################################
### testcase级变量:${RES_NAME}、${SEC_RES_NAME},通过关键字Get Random Name获取 ###
${RESOURCE_PATH}                    ${EXECDIR}\\Resource
${DOC_BODY_HEIGHT}                  document.body.scrollHeight
#################################### 栏目 ############################################
${COL_DASHBOARD}                        //div[text()="仪表盘"]
${COL_THESIS}                           //div[@class="menuItem" and contains(text(),"论文库")]
${COL_PERIODICAL}                       //div[@class="menuItem" and contains(text(),"期刊库")]
${COL_IMAGE}                            //div[@class="menuItem" and contains(text(),"图片库")]
${COL_TABLE}                            //div[@class="menuItem" and contains(text(),"表格库")]
${COL_FUND}                             //div[@class="menuItem" and contains(text(),"基金库")]
${COL_AUTHOR}                           //div[@class="menuItem" and contains(text(),"作者库")]
${COL_EXPERT}                           //div[@class="menuItem" and contains(text(),"专家库")]
${COL_ORG}                              //div[@class="menuItem" and contains(text(),"机构库")]
${COL_KEYWORD}                          //div[@class="menuItem" and contains(text(),"关键词库")]
${COL_VIDEO}                            //div[@class="menuItem" and contains(text(),"视频库")]
${COL_AUDIO}                            //div[@class="menuItem" and contains(text(),"音频库")]
${COL_DOCUMENT}                         //div[@class="menuItem" and contains(text(),"文档库")]
${SELECT_XPATH}                         //*[@id="area"]
${RESOURCE-CENTER}                      //*[@id="resource-center"]
${UPLOAD_DOCUMENT}                      //div[@class="btn1 operationBtns" and contains(text(),"上传文档")]
${UPLOAD_AUDIO}                         //div[@class="btn1 operationBtns" and contains(text(),"上传音频")]
${UPLOAD_VIDEO}                         //div[@class="btn1 operationBtns" and contains(text(),"上传视频")]
${IMPORT_KEYWORD}                       //div[@class="operationBtns" and contains(text(),"导入")]
${NEW_KEYWORD}                          //div[@class="operationBtns newKeyword" and contains(text(),"新建")]
${DELETE_KEYWORD}                       //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div/div[2]/div[1]
${DELETE_KEYWORD_CONFIRM}               //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div/div[2]/div[2]/div/div[3]/span/button[1]/span
${DELETE_SUCCESS}                       删除成功
${MORNING_GLORY_SPAN}                   //span[@class="chinese" and contains(text(),"牵牛花")]
${CHINESE_KEYWORD}                      //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div/div[2]/div[2]/div[2]/div/div[2]/form/div[1]/div/div[1]/div/input
${ENGLISH_KEYWORD}                      //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div/div[2]/div[2]/div[2]/div/div[2]/form/div[1]/div/div[2]/div/input
${NEW_KEYWORD_CONFIRM}                  //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div/div[2]/div[2]/div[2]/div/div[3]/span/button[1]/span
${DOCUMENT_NAME}                        //*[@id="app"]/div/div/div[2]/div/section/header/div[2]/div[2]/div[2]/div/div[2]/div/form/div[1]/div/div[1]/input
${AUDIO_NAME}                           //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div[2]/div[2]/div[2]/div/div[2]/div/form/div[1]/div/div/input
${VIDEO_NAME}                           //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div[2]/div[2]/div[2]/div/div[2]/div/form/div[1]/div/div/input
${KEYWORD_SELECT_FILE}                  //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div/div[2]/div[3]/div[2]/div/div[2]/div/div/div/button/span
${SELECT_FILE}                          //*[@id="app"]/div/div/div[2]/div/section/header/div[2]/div[2]/div[2]/div/div[2]/div/form/div[4]/div/div/div/span
${SELECT_FILE_CONFIRM}                  //*[@id="app"]/div/div/div[2]/div/section/header/div[2]/div[2]/div[2]/div/div[3]/span/button[1]/span
${AUDIO_SELECT_FILE_CONFIRM}            //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div[2]/div[2]/div[2]/div/div[3]/span/button[1]/span
${KEYWORD_SELECT_FILE_CONFIRM}          //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div/div[2]/div[3]/div[2]/div/div[3]/span/button[1]/span
${TRANSFER_LIST}                        //*[@id="app"]/div/div/div[2]/div/section/header/div[2]/div[1]/div[1]/img
${AUDIO_TRANSFER_LIST}                  //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div[2]/div[1]/div[1]/img
${TRANSFER_LIST_CLOSE}                  //*[@id="app"]/div/div/div[2]/div/section/header/div[2]/div[1]/div[2]/div/div[3]/span/button/span
${AUDIO_TRANSFER_LIST_CLOSE}            //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div[2]/div[1]/div[2]/div/div[3]/span/button/span
${SEARCH_INPUT}                         //*[@id="searchInput"]
${SEARCH_SPAN}                          //*[@id="app"]/div/div/div[2]/div/section/header/div[1]/div/div[3]/span
${AUDIO_SEARCH_SPAN}                    //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div[1]/div/div[3]/span
${TEST_DOC_TITLE}                       测试文档            #测试文档title
${TEST_AUDIO_TITLE}                     测试音乐            #测试音乐title
${TEST_VIDEO_TITLE}                     测试视频            #测试视频title
${REFRESH_BTN}                          //*[@id="app"]/div/div/div[2]/div/section/header/div[1]/img
${AUDIO_REFRESH_BTN}                    //*[@id="app"]/div/div/div[2]/div/div[2]/div[1]/div[1]/img
${MORNING_GLORY}                        牵牛花
*** Keywords ***
#################### 登录相关的公用关键字 ################################
Maximize Browser Window2
    ${system}                           Get Current System
    Run Keyword If                      ‘${system}‘ == ‘Windows‘    Maximize Browser Window
    ...       ELSE                      log                         linux
Open Browser To Login Page
    [Documentation]                 打开浏览器并导航到登录页
    Open Browser                    ${LOGIN_URL}            ${BROWSER}
    Maximize Browser Window2
    Set Selenium Speed              ${DELAY}
    Page Should Contain             方正学术出版云服务平台
Submit Credentials
    [Documentation]                 提交登录凭据
    Click Element                   //span[text()="登录"]
Login As Valid User
    [Documentation]                 以有效用户执行登录操作
    Input Text                      input                   ${VALID_USER}
    Input Text                      psd                     ${VALID_PASSWORD}
    Submit Credentials
    ${status}=                      Run Keyword And Return Status   Wait Until Page Contains Element                    resource-center            15s
Open Browser and Login
    [Documentation]                 打开浏览器并完成有效用户登录
    Open Browser To Login Page
    Login As Valid User
    Wait and Click Element          resource-center
    Wait Until Page Contains        论文库
    Select List Value By Label      area                    资源-UI自动化测试
    Wait Until Element Contains     //div[@class="uptodataDepotbox"][1]         资源-UI自动化测试
Open Browser and Login Temporary
   [Documentation]                 打开浏览器并完成有效用户登录
    Open Browser To Login Page
    Login As Valid User
    Wait Until Page Contains        精修工具下载
    :For           ${index}             IN RANGE            3
    \    Set_Browser_Implicit_Wait    10    #隐式等待
    \    ${Not_Contain}    Run_keyword_and_return_status    Page_Should_Not_Contain_Element       ${SELECT_XPATH}
    \    Run_keyword_if    ‘${Not_Contain}‘==‘True‘    Reload Page
    Select From List By Label       ${SELECT_XPATH}                   资源中心-测试
    Wait Until Element Contains     //*[@id="select2-area-container"]              资源中心-测试
Select Resource Center
    Wait and Click Element              ${RESOURCE-CENTER}
    Wait Until Page Contains            仪表盘
Open Browser and LoginEX
    [Documentation]                 打开浏览器并完成有效用户登录扩展
	[Arguments]                     ${username}		        ${password}
	Open Browser To Login Page
	Login As Valid UserEX			${username}		        ${password}
Login As Valid UserEX
    [Documentation]                 以有效用户执行登录操作扩展
	[Arguments]                     ${username}	            ${password}
	Wait Until Element Is Visible   input
	Input Text                      input	                ${username}
	Input Text                      psd	                    ${password}
	Submit Credentials
	Current Frame Contains          自动测试
####################### 页面操作相关的公用关键字 ################################################
Wait For Page Ready
    [Documentation]                 等待页面元素加载完成
    Sleep                           0.5s
    # Wait For Condition              return $.active == 0;
Go To Blank
    Go To                           about:blank
    Sleep                           1s
Go To Ref Page
    [Documentation]                 根据url跳转到新的页面
    [Arguments]                     ${url}                  ${text}=${EMPTY}
    Go To Blank
    Go To                           ${url}
    Wait For Page Ready
    Run Keyword Unless              ‘${text}‘ == ‘${EMPTY}‘         Wait Until Page Contains        ${text}     10s
Link Should Be Ref Column
    [Documentation]                 链接应该是一个栏目
    [Arguments]                     ${first_column}         ${text}=${EMPTY}
    Wait Until Page Contains Element                        ${first_column}
    Wait and Click Element          ${first_column}
    Wait Until Page Contains        ${text}
Close Popup Window
    [Documentation]                 通过页面右上角的叉号关闭弹出窗口
    Sleep                           1s
    Execute Javascript              var a=document.getElementsByClassName("layui-layer-ico layui-layer-close layui-layer-close1");a[0].click();
    Sleep                           1s
    # Execute Javascript              layer.close(layer.index)
Close Prompt Box
    [Documentation]                 关闭页面弹出的确定提示框
    [Arguments]                     ${chkPoint}=${EMPTY}
    Wait and Click Element          ${SYS_SAVE}
    Run Keyword Unless              ‘${chkPoint}‘==‘${EMPTY}‘       Wait Until Page Does Not Contain Element        ${chkPoint}
Close Popup Window and Prompt Box
    [Documentation]                 通过页面右上角的叉号关闭页面及弹出的确定提示框
    [Arguments]                     ${chkPoint}=${EMPTY}
    Close Popup Window
    Close Prompt Box
Link Should Be New Page
    [Documentation]                 链接应该跳转到新的页面
    [Arguments]                     ${locator}      ${chkPoint}=${EMPTY}
    Wait and Click Element          ${locator}
    Select Current Window
    Run Keyword Unless              ‘${chkPoint}‘==‘${EMPTY}‘       New Page Should Contain        ${chkPoint}
New Page Should Contain
    [Arguments]                     ${chkPoint}
    ${status}=                      Run Keyword And Return Status   Wait Until Page Contains        ${chkPoint}
    Run Keyword If                  ‘${status}‘==‘False‘            Run Keywords    Reload Page  AND  Wait Until Page Contains        ${chkPoint}
Select Current Window
    Select Window                   new
Close New Page
    [Documentation]                 关闭新打开的页面
    Close Window
    Select Window
    Sleep                           1s
Close Multi New Page
    Close New Page
    Select Current Window
    Close New Page
Wait Until Shade Is Not Visible
    [Documentation]                 等待直到遮罩消失
    Wait Until Page Does Not Contain Element        ${SHADE_LAYER}                  7s
Drag Scrollbar Down
    [Documentation]                 竖向滚动条滚动到最下方
    [Arguments]                     ${locator}
    # Execute Javascript              document.body.scrollTop = 2000
    Wait Until Page Contains Element                        ${locator}
    Sleep                           1s
    Execute Javascript              document.getElementById(‘${locator}‘).scrollTop=10000
Drag Page Scrollbar Down
    [Documentation]                 根据指定距离,拖动竖向滚动条。默认拖动到底部
    [Arguments]                     ${scroll_height}=${DOC_BODY_HEIGHT}
    Execute Javascript              window.scrollTo(0,${scroll_height})
    Sleep                           0.5s
Select Resource Filter
    [Documentation]                 选择资源列表过滤器
    [Arguments]                     ${status}
    Select List Value By Label      ${STATUS_FILTER}                ${status}
Select Resource Item From List
    [Documentation]                 列表方式下选择资源列表项,列表项从1开始
    [Arguments]                     ${row}
    ${actual_row}    Evaluate       ${row}-1
    # Set Suite Variable              ${ACTUAL_ROW}    ${actual_row}
    Wait and Select Checkbox        xpath=//input[@name="btSelectItem" and @data-index="${actual_row}"]
Select Resource Item From PicList
    [Documentation]                 图文平铺方式下选择资源列表项,列表项从1开始
    [Arguments]                     ${row}
    ${resCount}=  Get Matching Xpath Count          xpath=//a[@class="img"]
    Run Keyword If                  ${resCount}>1   Wait and Click Link             xpath=//*[@id="resPicList"]/ul/li[${row}]/div[2]/a
    Run Keyword If                  ${resCount}==1  Wait and Click Link             ${PICLIST_SINGLEIMG_RESOURCE}
Select Resource By Name From List
    [Documentation]                 列表方式下通过资源名称选中资源
    [Arguments]                     ${name}=${RES_NAME}
    Wait and Select Checkbox        //*[@id="resList"]//a[@title="${name}"]/ancestor::tr//input
Select Resource By Name From PicList
    [Documentation]                 图文平铺方式下通过资源名称选中资源
    [Arguments]                     ${name}=${RES_NAME}
    Wait and Click Element          //*[@id="resPicList"]//a[@class="img" and @title="${name}"]
Open Resource Item From List
    [Documentation]                 列表方式下打开资源项,列表项从1开始
    [Arguments]                     ${row}
    ${resCount}=  Get Matching Xpath Count          xpath=//*[@id="resList"]/tbody/tr
    Run Keyword If                  ${resCount}>1   Link Should Be New Page         //*[@id="resList"]/tbody/tr[${row}]/td[4]/a
    Run Keyword If                  ${resCount}==1  Link Should Be New Page         ${LIST_SINGLE_RESOURCE}
Open Resource Item From PicList
    [Documentation]                 图文平铺方式下打开资源项,列表项从1开始
    [Arguments]                     ${row}
    ${resCount}=  Get Matching Xpath Count          xpath=//a[@class="img"]
    Run Keyword If                  ${resCount}>1   Link Should Be New Page         xpath=//*[@id="resPicList"]/ul/li[${row}]/p/a
    Run Keyword If                  ${resCount}==1  Link Should Be New Page         ${PICLIST_SINGLE_RESOURCE}
Open Detail By Name From List
    [Documentation]                 列表方式下打开资源详情页
    [Arguments]                     ${name}=${RES_NAME}
    Link Should Be New Page         //*[@id="resList"]//a[@title="${name}"]
Open Detail By Name From PicList
    [Documentation]                 图文平铺方式下打开资源详情页
    [Arguments]                     ${name}=${RES_NAME}
    Link Should Be New Page         //*[@id="resPicList"]//a[@ng-click="openDetail(doc.DocID)" and @title="${name}"]
Wait Until Toolbar Ready
    [Documentation]                 等待直到工具栏刷新完成(后续将根据开发新增的页面属性进行判断)
    [Arguments]                     ${locator}
    Sleep                           0.5s
    Wait Until Page Contains Element                real_${locator}
    Sleep                           0.5s
Wait Until Toast Closed
    [Documentation]                 等待直到toast提示框关闭
    [Arguments]                     ${locator}
    Wait Until Page Contains                        ${locator}
    Wait Until Page Does Not Contain                ${locator}
Switch List Mode
    [Documentation]                 切换列表显示方式:列表方式、图文平铺方式
    [Arguments]                     ${locator}
    Wait and Click Element          ${locator}
Link Should Be Download
    [Documentation]                 链接应该是一个可下载的资源
    [Arguments]                     ${locator}
    ${ref}=  Get Element Attribute  ${locator}@href
    Should Contain Any              ${ref}         .zip    .rar    .exe  .docx  .doc
####################### 基本操作相关的公用关键字 ###############################################
Click Toolbar Button
    [Documentation]                 单击操作区中的按钮
    [Arguments]                     ${locator}
    Sleep                           2s
    Wait and Click Link             ${locator}
Click Toolbar Button In Menu
    [Documentation]                 单击操作区更多菜单中的按钮
    [Arguments]                     ${locator}
    Wait Until Page Contains Element                        ${locator}
    Sleep                           1s
    Execute Javascript              $("#${locator}").click()
    Wait For Page Ready
Select Resource Categories
    [Documentation]                 选择分类树中的分类值
    [Arguments]                     ${locator}    ${frame_locator}=${EMPTY}
    # Run Keyword Unless              ‘${frame_locator}‘==‘${EMPTY}‘          UnSelect Frame
    Run Keyword Unless              ‘${frame_locator}‘==‘${EMPTY}‘          Wait and Select Frame           ${frame_locator}
    # Wait and Double Click Element   ${locator}
    Wait Until Element Is Visible   ${locator}
    Click Element                   ${locator}
    Click Element                   //input[@value="选择"]
    Run Keyword Unless              ‘${frame_locator}‘==‘${EMPTY}‘          UnSelect Frame
Select Date
    [Documentation]                 选择时间控件中的值
    [Arguments]                     ${year_month}      ${date}     ${frame_locator}=${EMPTY}
    Run Keyword Unless              ‘${frame_locator}‘==‘${EMPTY}‘          Wait and Select Frame   ${frame_locator}
    Click Element                   ${year_month}
    Click Element                   ${date}
    Run Keyword Unless              ‘${frame_locator}‘==‘${EMPTY}‘          UnSelect Frame
Select Date For Today
    [Documentation]                 选择时间控件中的“今天”
    [Arguments]                     ${locator}      ${frame_locator}=${EMPTY}
    Run Keyword Unless              ‘${frame_locator}‘==‘${EMPTY}‘          Wait and Select Frame   ${frame_locator}
    Click Element                   ${locator}
    Run Keyword Unless              ‘${frame_locator}‘==‘${EMPTY}‘          UnSelect Frame
Click Save Button
    [Documentation]                 单击保存按钮
    [Arguments]                     ${locator}
    Sleep                           0.5s
    Wait and Click Element          ${locator}
Click Cancel Button
    [Documentation]                 单击取消按钮
    [Arguments]                     ${locator}
    Wait and Click Element          ${locator}
Click Next Step Button
    [Documentation]                 单击下一步按钮
    [Arguments]                     ${locator}
    Wait and Click Element          ${locator}
Click Previous Step Button
    [Documentation]                 单击上一步按钮
    [Arguments]                     ${locator}
    Wait and Click Element          ${locator}
Click Upload Button
    [Documentation]                 单击单个文件上传按钮
    [Arguments]                     ${upload_file}
    Wait and Click Link             ${upload_file}
Click Batch Upload Button
    [Documentation]                 单击批量文件上传按钮
    [Arguments]                     ${batch_upload}
    Wait and Click Link             ${batch_upload}
Click SelectAll CheckBox
    [Documentation]                 单击选择全部复选框
    [Arguments]                     ${selectall_locator}
    Wait and Select Checkbox        ${selectall_locator}
Click Search Button
    [Arguments]                     ${search}
    Wait and Click Link             ${search}
Select Search Type By Label
    [Documentation]                 通过标签选择检索类别
    [Arguments]                     ${locator}      ${label}
    Wait Until Element Is Visible   ${locator}
    Select From List By label       ${locator}      ${label}
Select Search Type By Index
    [Documentation]                 通过标签选择检索类别
    [Arguments]                     ${locator}      ${Index}
    Wait Until Element Is Visible   ${locator}
    Wait For Page Ready
    Select From List By Index       ${locator}      ${Index}
Input Search Word
    [Documentation]                 输入检索词
    [Arguments]                     ${locator}      ${search_word}
    Wait Until Element Is Visible   ${locator}
    Input Text                      ${locator}      ${search_word}
Delete Record
    [Documentation]                 删除指定资源记录
    [Arguments]                     ${locator}
    Wait Until Element Is Visible   ${locator}
    Click Element                   ${locator}
    Close Prompt Box
Trash Should Contains
    [Documentation]                         验证回收站中应该包含指定的资源
    [Arguments]                     ${name}
    Click Element                   -2_anchor
    Wait Until Page Contains        ${name}
Select Category By Name From CatNav
    [Documentation]                         根据名称选择分类导航下的分类
    [Arguments]                             ${name}
    Sleep                           3s
    Wait and Click Element                  //a[contains(@class,"jstree-anchor") and contains(@title,"${name}")]
### 上传相关 ###
Wait Until Upload Finished
    [Documentation]                 等待上传完成
    [Arguments]                     ${check_point}
    Wait Until Page Contains        ${check_point}
    # Wait Until Page Does Not Contain                ${check_point}
Upload File Until Finished
    [Documentation]                 通过原生上传控件,上传文件
    [Arguments]                     ${locator}      ${file_path}        ${check_point}=${EMPTY}
    Wait Until Page Contains Element                ${locator}
    Choose File                     ${locator}      ${file_path}
    Run Keyword Unless              ‘${check_point}‘==‘${EMPTY}‘        Wait Until Upload Finished      ${check_point}
Upload Large Files
    [Documentation]                 通过最新的自定义上传控件,上传大文件
    [Arguments]                     ${upload_locator}      ${file_path}
    Wait and Click Element          ${upload_locator}
    uploadfile                      ${file_path}
    Sleep                           1s
Upload Docs Files
    [Documentation]                 通过最新的自定义上传控件,上传大文件
    [Arguments]                     ${upload_locator}
    Wait and Click Element          ${upload_locator}
    Choose File                     xpath=//input[@name="file"]   ${EXEcdIR}\\testFiles\\docs\\test001.docx
    Sleep                           1s
JS Click Button By Name
    [Arguments]                     ${locator}
    Execute Javascript              $("*[name=‘${locator}‘]").click()
####################### 基于原生关键字的的公用关键字 ###############################################
Wait and Click Link
    [Documentation]                 等待元素出现并单击链接
    [Arguments]                     ${locator}
    Wait Until Element Is Visible   ${locator}
    # Sleep                           0.5s
    Click Link                      ${locator}
    Wait For Page Ready
Wait and Click Element
    [Documentation]                 等待元素出现并单击元素
    [Arguments]                     ${locator}
    Wait Until Element Is Visible   ${locator}          10s
    # Sleep                           0.5s
    Click Element                   ${locator}
    Wait For Page Ready
Move Menu and Click Link
    [Documentation]                 等待悬浮菜单中的元素出现并单击元素
    [Arguments]                     ${hover_locator}    ${opt_locator}
    Sleep                           1s
    Wait Until Element Is Visible   ${hover_locator}
    Mouse Down                      ${hover_locator}
    Click Link                      ${opt_locator}
Move Over and Click Link
    [Documentation]                 等待悬浮菜单中的元素出现并单击元素
    [Arguments]                     ${hover_locator}    ${opt_locator}
    Sleep                           1s
    Wait Until Element Is Visible   ${hover_locator}
    Mouse Over                      ${hover_locator}
    Click Link                      ${opt_locator}
Wait and Select Checkbox
    [Documentation]                 等待复选框出现并选中复选框
    [Arguments]                     ${locator}
    Wait Until Element Is Visible   ${locator}
    Select Checkbox                 ${locator}
    Wait For Page Ready
Wait and Select Frame
    [Documentation]                 等待frame出现并单击frame
    [Arguments]                     ${locator}
    Wait Until Element Is Visible   ${locator}
    Select Frame                    ${locator}
Wait and Double Click Element
    [Documentation]                 等待元素出现并双击元素
    [Arguments]                     ${locator}
    Wait Until Element Is Visible   ${locator}
    Double Click Element            ${locator}
    Wait For Page Ready
Select List Value By Label
    [Documentation]                 选择下拉列表中的值
    [Arguments]                     ${locator}                      ${label}
    Wait Until Element Is Visible   ${locator}                      10s
    Select From List By Label       ${locator}                      ${label}
    Wait For Page Ready
Select List Value By Index
    [Documentation]                 选择下拉列表中的值
    [Arguments]                     ${locator}                      ${index}
    Wait Until Element Is Visible   ${locator}
    Select From List By Index       ${locator}                      ${index}
    Wait For Page Ready
Element Text Should Be
     [Documentation]                验证元素内容
    [Arguments]                     ${locator}                      ${text}
    ${value}=                       Get Text                        ${locator}
    ${value}=                       Del Newlines                    ${value}
    ${value}=                       Del Space                       ${value}
    Run Keyword And Continue On Failure                             Should Be Equal                 ${value}                        ${text}
    Capture Page Screenshot
Element Text Should Contain
     [Documentation]                验证元素内容
    [Arguments]                     ${locator}                      ${text}
    ${value}=                       Get Text                        ${locator}
    Run Keyword And Continue On Failure                             Should Contain                 ${value}                         ${text}
    Capture Page Screenshot
Element Text Should Not Contain
     [Documentation]                验证元素内容
    [Arguments]                     ${locator}                      ${text}
    ${value}=                       Get Text                        ${locator}
    Run Keyword And Continue On Failure                             Should Not Contain             ${value}                         ${text}
    Capture Page Screenshot
Element Attribute Should Contain
    [Arguments]                     ${locator}                      ${value}
    ${attr}                        Get Element Attribute            ${locator}                     Class
    Run Keyword And Continue On Failure                             Should Contain                 ${attr}                         ${value}
    Capture Page Screenshot
Element Count Should Be
     [Documentation]                验证元素数量
    [Arguments]                     ${locator}                      ${count}
    ${value}=                       Get Matching Xpath Count        ${locator}
    Run Keyword And Continue On Failure                             Should Be Equal                 ${value}                        ${count}
    Capture Page Screenshot
Element Should Not Be Empty
    [Documentation]                验证元素值不应该为空
    [Arguments]                     ${locator}
    ${value}=                       Get Text                        ${locator}
    Run Keyword And Continue On Failure                             Should Not Be Empty             ${value}
    Capture Page Screenshot
####################### 逻辑运算相关的公用关键字 ###############################################
Get Current File Parent Path
    ${parent_path}=    Get Parent Path
    log         ${parent_path}
    Set Suite Variable              ${PARENT_PATH}    ${parent_path}
    log         ${PARENT_PATH}
##########################   资源中心公用关键字   ###################################
Select Library Common Keywords
    Select Resource Center
    :For           ${index}             IN RANGE            3
    \    Set_Browser_Implicit_Wait    10    #隐式等待
    \    ${Not_Contain}    Run_keyword_and_return_status    Page_Should_Not_Contain_Element       ${COL_VIDEO}
    \    Run_keyword_if    ‘${Not_Contain}‘==‘True‘    Reload Page
    Wait and Click Element              ${COL_VIDEO}
Keyword Input Title Info
    [Documentation]                     输入标题名称等信息
    [Arguments]                         ${title}            ${context}
    ${title}=  Generate.Generate Stamp  ${title}_
    Set Suite Variable                  ${ARTICLE_TOPIC}    ${title}
    Input Text                          ${CHINESE_KEYWORD}           ${ARTICLE_TOPIC}
    Input Text                          ${ENGLISH_KEYWORD}           ${context}
#-----------------------------------------------------------------------------------
########################### 文档库关键字 上传文档###################################
DocumentLibrary Upload Function Verification
    Select Library Common Keywords
    Drag Page Scrollbar Down            1000
    Wait and Click Element              ${COL_DOCUMENT}
    Wait Until Page Contains Element    ${UPLOAD_DOCUMENT}
    Wait and Click Element              ${UPLOAD_DOCUMENT}
    Wait Until Page Contains Element    ${DOCUMENT_NAME}
    Input Text                          ${DOCUMENT_NAME}   ${TEST_DOC_TITLE}
    Execute Javascript  document.getElementsByClassName(‘chooseFile‘)[0].click()
    Choose File                     xpath=//input[@name="file"]   ${EXEcdIR}\\testFiles\\docs\\test001.docx
    Sleep                           1s
    Wait and Click Element              ${SELECT_FILE_CONFIRM}
########################### 文档库关键字 传输列表###################################
DocumentLibrary Transfer list Verification
    Wait and Click Element              ${TRANSFER_LIST}
    Page Should Contain                 test001.docx
    Wait and Click Element              ${TRANSFER_LIST_CLOSE}
########################### 文档库关键字 搜索###################################
DocumentLibrary Searach Verification
    Input Text                          ${SEARCH_INPUT}             ${TEST_DOC_TITLE}
    Wait and Click Element              ${SEARCH_SPAN}
    Wait Until Page Contains            ${TEST_DOC_TITLE}
########################### 文档库关键字 刷新###################################
DocumentLibrary REFRESH Verification
    Wait and Click Element              ${REFRESH_BTN}
#-----------------------------------------------------------------------------------
########################### 音频库关键字 上传音频###################################
AudioLibrary Upload Function Verification
    Select Library Common Keywords
    Drag Page Scrollbar Down            1000
    Wait and Click Element              ${COL_AUDIO}
    Wait Until Page Contains Element    ${UPLOAD_AUDIO}
    Wait and Click Element              ${UPLOAD_AUDIO}
    Wait Until Page Contains Element    ${AUDIO_NAME}
    Input Text                          ${AUDIO_NAME}   ${TEST_AUDIO_TITLE}
    Execute Javascript  document.getElementsByClassName(‘chooseFile‘)[0].click()
    Choose File                     xpath=//input[@name="file"]   ${EXEcdIR}\\testFiles\\audios\\mp3\\blue001.mp3
    Sleep                           1s
    Wait and Click Element              ${AUDIO_SELECT_FILE_CONFIRM}
########################### 音频库关键字 传输列表###################################
AudioLibrary Transfer list Verification
    Wait and Click Element              ${AUDIO_TRANSFER_LIST}
    Page Should Contain                 blue001.mp3
    Wait and Click Element              ${AUDIO_TRANSFER_LIST_CLOSE}
########################### 音频库关键字 搜索###################################
AudioLibrary Searach Verification
    Input Text                          ${SEARCH_INPUT}            ${TEST_AUDIO_TITLE}
    Wait and Click Element              ${AUDIO_SEARCH_SPAN}
    Wait Until Page Contains            ${TEST_AUDIO_TITLE}
########################### 音频库关键字 刷新###################################
AudioLibrary REFRESH Verification
    Wait and Click Element              ${AUDIO_REFRESH_BTN}
#-----------------------------------------------------------------------------------
########################### 视频库关键字 上传视频###################################
VideoLibrary Upload Function Verification
    Select Library Common Keywords
    Wait and Click Element              ${COL_VIDEO}
    Wait Until Page Contains Element    ${UPLOAD_VIDEO}
    Wait and Click Element              ${UPLOAD_VIDEO}
    Wait Until Page Contains Element    ${VIDEO_NAME}
    Input Text                          ${VIDEO_NAME}   ${TEST_VIDEO_TITLE}
    Execute Javascript  document.getElementsByClassName(‘chooseFile‘)[0].click()
    Choose File                     xpath=//input[@name="file"]   ${EXEcdIR}\\testFiles\\Videos\\mov001.mp4
    Sleep                           1s
    Wait and Click Element              ${AUDIO_SELECT_FILE_CONFIRM}
    Sleep                           5s
########################### 视频库关键字 传输列表###################################
VideoLibrary Transfer list Verification
    Wait and Click Element              ${AUDIO_TRANSFER_LIST}
    Page Should Contain                 mov001.mp4
    Wait and Click Element              ${AUDIO_TRANSFER_LIST_CLOSE}
########################### 视频库关键字 搜索###################################
VideoLibrary Searach Verification
    Input Text                          ${SEARCH_INPUT}            ${TEST_VIDEO_TITLE}
    Wait and Click Element              ${AUDIO_SEARCH_SPAN}
    Wait Until Page Contains            ${TEST_VIDEO_TITLE}
########################### 视频库关键字 刷新###################################
VideoLibrary REFRESH Verification
    Wait and Click Element              ${AUDIO_REFRESH_BTN}
#-----------------------------------------------------------------------------------
########################### 关键词库关键字 导入关键词################################
Keywords Import Function Verification
    Select Library Common Keywords
    Wait and Click Element              ${COL_KEYWORD}
    Wait Until Page Contains Element    ${IMPORT_KEYWORD}
    Wait and Click Element              ${IMPORT_KEYWORD}
    Wait Until Page Contains Element    ${KEYWORD_SELECT_FILE}
    Wait and Click Element              ${KEYWORD_SELECT_FILE}
    Choose File                     xpath=//input[@name="file"]   ${EXEcdIR}\\testFiles\\excel\\excel001.xlsx
    Wait Until Page Contains            excel001.xlsx
    # Press keys           ${KEYWORD_SELECT_FILE_CONFIRM}               \\27
    Wait and Click Element              ${KEYWORD_SELECT_FILE_CONFIRM}
    Wait Until Page Contains            蜗牛
#-----------------------------------------------------------------------------------
########################### 关键词库关键字 导入关键词################################
New Keywords Verification
    Select Library Common Keywords
    Wait and Click Element              ${COL_KEYWORD}
    Wait Until Page Contains Element    ${NEW_KEYWORD}
    Wait and Click Element              ${NEW_KEYWORD}
    Wait Until Page Contains Element    ${CHINESE_KEYWORD}
    Keyword Input Title Info            ${MORNING_GLORY}    Morning glory
    Wait and Click Element              ${NEW_KEYWORD_CONFIRM}
    Page Should Contain                 ${MORNING_GLORY}
    Wait and Click Element              ${MORNING_GLORY_SPAN}
    Execute Javascript  document.getElementsByClassName(‘operationBtns‘).click()
    Wait and Click Element              ${DELETE_KEYWORD_CONFIRM}
    Page Should Not Contain
原文:https://www.cnblogs.com/Yanss/p/11981122.html