简体   繁体   English

Robot Framework:无法使用文件中包含unicode的变量来运行Robot测试用例

[英]Robot Framework: Unable to run the Robot test case with variables that has unicode in the file

When I try to run the following script I get the error: 当我尝试运行以下脚本时,出现错误:

UnicodeDecodeError: 'utf8' codec can't decode byte 0xa5 in position 63: invalid start byte UnicodeDecodeError:“ utf8”编解码器无法解码位置63的字节0xa5:无效的起始字节

Note- I have to use the same variable , so alternative locators But if remove the yen symbol it works fine-` how to fix it 注意-我必须使用相同的变量,因此可以使用其他定位符。但是,如果删除日元符号,它将正常工作-如何解决它

***Settings***
Library    Selenium2Library

*** Variables ***
${DC_CURRENCY_SELECTOR_VERIFY}   xpath=//label[contains(text(),' ¥ 10')] 


***Test Cases***
Test browser
    open browser    http://google.com    chrome

You can use the string keywords provided by Robot framework in order to encode your variable. 您可以使用Robot框架提供的字符串关键字来对变量进行编码。 I believe something like this will work: 我相信这样会起作用:

${DC_CURRENCY_SELECTOR_VERIFY} =    Encode String To Bytes    ${DC_CURRENCY_SELECTOR_VERIFY}   ASCII    errors=ignore

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM