Testing 由于源字符串,无法在Robot测试中比较字符串

Testing 由于源字符串,无法在Robot测试中比较字符串,testing,automation,scripting,robotframework,Testing,Automation,Scripting,Robotframework,我试图做的是从表中获取一条记录,并将其与web UI中元素中的文本进行比较 我对docker执行exec命令,并运行命令以拉出运行正常的top记录 +++docker exec-it 60493033cec6/bin/sh-c'mysql-uroot-ppassword-Bse“使用requestdb;从infra\u active\u requests limit 1中选择REQUEST\u ID;” 上面的echo命令输出以下内容:- ++ req_id=$'0327902d-6346-4c

我试图做的是从表中获取一条记录,并将其与web UI中元素中的文本进行比较

我对docker执行exec命令,并运行命令以拉出运行正常的top记录

+++docker exec-it 60493033cec6/bin/sh-c'mysql-uroot-ppassword-Bse“使用requestdb;从infra\u active\u requests limit 1中选择REQUEST\u ID;”

上面的echo命令输出以下内容:-

++ req_id=$'0327902d-6346-4c61-94b2-9da532bc7ef3\r'

++ echo Record: $'0327902d-6346-4c61-94b2-9da532bc7ef3\r'    

Record: 0327902d-6346-4c61-94b2-9da532bc7ef3          notice there is no \r here

++ export $'req_id=0327902d-6346-4c61-94b2-9da532bc7ef3\r'

++ req_id=$'0327902d-6346-4c61-94b2-9da532bc7ef3\r' `// \r included in the string here.
在测试中,我使用下面的语句来比较字符串

${result}  Get Text  xpath = //*[@id="mat-tab-content-0-0"]/div/mat-table/mat-row[1]/mat-cell[1]/a
Should be equal as Strings   ${result}    ${REQ_ID}  //REQ_ID has the request id created before
${REQ_ID} =  Fetch From Left ${REQ_ID} \r `     // to remove the \r
我试图使用以下命令将数据库查询的结果值设置为${RESULT}

${REQ\u ID}=Fetch From Left${REQ\u ID}\r

我这样做对吗?字符串库已导入

我得到的错误是:-

1. No keyword with name 'Fetch From Left ${REQ_ID} \r' found.


Fetch from left
关键字中,关键字和参数之间至少应有2个空格。在您的代码中,似乎只有一个介于
从左侧获取
${REQ\u ID}
\r
之间。这就是为什么找到名为'Fetch From Left${REQ\u ID}\r'的
No关键字。
错误

此外,如果由于
\r
字符而无法比较字符串,则应在删除
/r
后比较字符串。交换行号2和3的位置

${result}  Get Text  xpath = //*[@id="mat-tab-content-0-0"]/div/mat-table/mat-row[1]/mat-cell[1]/a
${REQ_ID} =  Fetch From Left  ${REQ_ID}  \r      // to remove the \r
Should be equal as Strings   ${result}    ${REQ_ID}  //REQ_ID has the request id created before

我几乎可以肯定这应该行得通。如果没有,请进行注释。

从左侧获取
关键字中,关键字和参数之间应至少有2个空格。在您的代码中,似乎只有一个介于
从左侧获取
${REQ\u ID}
\r
之间。这就是为什么找到名为'Fetch From Left${REQ\u ID}\r'的
No关键字。
错误

此外,如果由于
\r
字符而无法比较字符串,则应在删除
/r
后比较字符串。交换行号2和3的位置

${result}  Get Text  xpath = //*[@id="mat-tab-content-0-0"]/div/mat-table/mat-row[1]/mat-cell[1]/a
${REQ_ID} =  Fetch From Left  ${REQ_ID}  \r      // to remove the \r
Should be equal as Strings   ${result}    ${REQ_ID}  //REQ_ID has the request id created before
我几乎可以肯定这应该行得通。如果没有,请发表评论