例如,我们有:
Get ticket value
Wait Until Element is Visible ${ticketDescription}
${ticketDescValue}= Execute Javascript return window.document.querySelector('p[class*="ticket-description"]').innerHTML.toString()
Verify if ticket value matches
Element Text Should Be ${some_locator} ${ticketDescValue}
其中,${ticketDescValue}将是预期的文本
测试用例示例:
^{pr2}$有没有办法在现有关键字之间共享变量? 在Java中,我可以使用getter和setter来处理这个问题。 或者发送参数到方法等。。。在
如何使用Robot框架实现它?在
更好的方法是修改您的
Get ticket value
关键字以返回参数,并修改您的Verify if ticket value matches
关键字以票据值作为参数。这样就不需要使用全局变量。在那么你的测试应该是这样的:
^{pr2}$我把所有的参数名都改为不同的,以强调它们不一定都是相同的——但是如果你愿意,你可以让它们都一样。在
您需要在赋值行后使用类似于下面的内容将变量值设置为全局变量或套件变量:
或者,可以从第一个关键字返回变量,并将其作为参数传递到第二个关键字
相关问题 更多 >
编程相关推荐