几个常用关键字的使用笔记(一)

一、

Get Element Count

获取相同element的个数(比如新建多个账户然后去删除时,判断可删除的画像个数,也就是说判断有多少个删除按钮)

其中:

element的写法为相同的前缀,不同的地方以*替代

e.g.:

//*[@id="app"]/div/div/section/div/div[1]/div[1]/span[2]/i

//*[@id="app"]/div/div/section/div/div[2]/div[1]/span[2]/i

//*[@id="app"]/div/div/section/div/div[3]/div[1]/span[2]/i

写为:

${x}    Get Element Count    //*[@id="app"]/div/div/section/div/div[*]/div[1]/span[2]/i

即为返回页面该层相同元素的个数

 

二、

Run Keyword And Return Status

获取后面关键字的返回状态,True/False

其中:

e.g.:

${judjement}    Run Keyword And Return Status    page should contain element    //[@id="app"]/div/div/div/div[2]/div/div[2]/a/i

即为返回页面是否含有该元素的布尔值

 

三、

Create_List

构建列表

其中:

空值可以不写跳过就好了

e.g.:

@{address}    Create List    2010    2011    2012    2013    2014

应用时需要加上下标(下标从0开始)

${x}    Set Variable    @{address}[1]

Log    ${x}

为2011

 

四、

Create_Dictionary

构建字典

其中:

空格中填入的键值对形式。空value可以,空key不行,和dictionary一样。key不能重复

e.g.:

&{dic}    Create Dictionary    年份1=2010    年份2=2011    年份3=2012

引用时需要加上key

${x}    Set Variable    &{dic}[年份1]

Log    ${x}

为2010

 

五、

Element_Text_Should_Not_Be

元素包含的内容不包含

Arguments:

[ locator | not_expected | message=None | ignore_case=False ]

 

六、

Get Element Attribute

获取元素的属性值(id、class、type、style etc...)

Arguments:

[ locator | attribute ]

e.g.:

${e}    Get Element Attribute    //*[@id="app"]/div/div/div/div[3]/div[1]/ul/li[5]/a    class

Log    ${e}

为active

打印的结果是当前激活的按钮的元素属性(即class="active")

 

七、

Element_Attribute_Value_Should_Be

获取元素的属性值并与预想值比较(断言)

其中:

Arguments:

[ locator | attribute | expected | message=None ]

e.g.:

Element Attribute Value Should Be    //*[@id="app"]/div/div/div/div[3]/div[1]/ul/li[${i}]/a    class    active

其中${i}是循环取值后的变量

每次循环后取得当前的element的class的属性值需为active,则当前的断言通过

 

八、

Create List

构建列表

其实构建列表时,参数应该写${X},而不是写@{X},否则定义的不是一个List

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值