(一)robotfromwork自动化--string库翻译

用于字符串操作和验证的测试库。String 是Robot Framework用于操作字符串的标准库

来自BuiltIn 库的以下关键字  也可以与字符串一起使用:

  • Catenate
  • Get Length
  • Length Should Be
  • Should (Not) Be Empty
  • Should (Not) Be Equal (As Strings/Integers/Numbers)
  • Should (Not) Match (Regexp)
  • Should (Not) Contain
  • Should (Not) Start With
  • Should (Not) End With
  • Convert To String
  • Convert To Bytes

共有30个关键字。 

Convert To Lowercase   Convert To Uppercase · Decode Bytes To String · Encode String To Bytes · Fetch From Left · Fetch From Right · Generate Random String · Get Line · Get Line Count ·Get Lines Containing String · Get Lines Matching Pattern · Get Lines Matching Regexp · Get Regexp Matches · Get Substring · Remove String · Remove String Using Regexp · Replace String ·Replace String Using Regexp · Should Be Byte String · Should Be Lowercase · Should Be String · Should Be Titlecase · Should Be Unicode String · Should Be Uppercase · Should Not Be String ·Split String · Split String From Right · Split String To Characters · Split To Lines · Strip String

关键字 参数 文档
Convert To Lowercase string

将字符串转换为小写。

例子:

${str1} = Convert To Lowercase ABC
${str2} = Convert To Lowercase 1A2c3D
Should Be Equal ${str1} abc
Should Be Equal ${str2} 1a2c3d

Robot Framework 2.8.6中的新功能。

Convert To Uppercase string

将字符串转换为大写。

例子:

${str1} = Convert To Uppercase abc
${str2} = Convert To Uppercase 1a2C3d
Should Be Equal ${str1} ABC
Should Be Equal ${str2} 1A2C3D

Robot Framework 2.8.6中的新功能。

Decode Bytes To String

bytes, encoding,

errors=strict

使用给定的解码将给定bytes 的Unicode字符串  解码  encoding

errors 如果解码某些字节失败,参数控制该怎么做。decode Python中方法接受的所有值  都是有效的,但实际上以下值最有用:

  • strict:如果无法解码字符,则失败(默认)
  • ignore:忽略无法解码的字符
  • replace:替换无法使用替换字符解码的字符

例子:

${string} = Decode Bytes To String ${bytes} UTF-8  
${string} = Decode Bytes To String ${bytes} ASCII errors=ignore

如果需要将Unicode字符串转换为字节字符串,请使用  Encode String To Bytes;如果 需要将任意对象转换为Unicode字符串,请使用  Convert To String in  BuiltIn

Encode String To Bytes

string, encoding,

errors=strict

string 使用给定的代码将给定的Unic

  • 0
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值