我想做的是从表中获取一条记录,并将其与Web UI元素中的文本进行比较。
我执行到docker并运行命令以提取正常工作的顶部记录
+++ docker exec -it 60493033cec6 /bin/sh -c 'mysql -uroot -ppassword -Bse "use requestdb; select REQUEST_ID from infra_active_requests limit 1;"'
上面的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_ID} = Fetch From Left ${REQ_ID} \r
我这样做正确吗?字符串库已导入
我得到的错误是:-
1. No keyword with name 'Fetch From Left ${REQ_ID} \r' found.
或
2. 0327902d-6346-4c61-94b2-9da532bc7ef3 != 0327902d-6346-4c61-94b2-9da532bc7ef3 ///when run without the fetch from left command
答案 0 :(得分:2)
在Fetch from left
关键字中,关键字和参数之间至少应有2个空格。在您的代码中,Fetch From Left
,${REQ_ID}
和\r
之间似乎只有一个。这就是为什么出现No keyword with name 'Fetch From Left ${REQ_ID} \r' found.
错误的原因。
此外,如果由于\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
我几乎确定这应该可行。如果没有,请发表评论。