【发布时间】:2018-01-26 00:33:46
【问题描述】:
我有以下问题:
- 我有一个隐藏的复选框,还有另一个图层用来使它美观和闪亮
- 我可以通过访问其 ID 轻松更改其值,但我还需要使用我的自定义定位器访问此元素,该定位器使用 xpath(必须保持可变)
所以,这是我的脚本:
Custom Select Checkbox id=my_checkbox #that works fine
Custom Select Checkbox customLocatorStrat #that doesn't work at all
*** Keywords ***
Custom Select Checkbox
[Arguments] ${locator} ${timeout}=${global_timeout}
Execute Javascript document.getElementById("${resultLocator}").checked = true;
OR
${el}.checked = true; #need to get the ${el} variable if the ${locator is not an id}
My Custom Locator
[Arguments] ${criteria} ${tag} ${constraints}
... #assembling xpath
${el}= Get Webelements xpath=${path}
[Return] ${el}
定位器策略没有问题 - 它运行良好。我只需要在我的自定义选择复选框关键字中使用/强制它。我需要获取 ${el} 变量,并且考虑到有多个自定义定位器关键字直接调用它对我不起作用。知道该怎么做吗?非常感谢。
【问题讨论】:
标签: python robotframework selenium2library