Accessing elements located by custom locator strategy with Javascript

心已入冬 提交于 2019-12-02 10:12:39

Custom locators in the selenium2library require activation through the Add Location Strategy [Doc]. This seems to me to be the missing from your example.

*** Test Cases ***
Test Case
    Add Location Strategy   custom  Custom Locator Strategy
    Page Should Contain Element custom=my_id

*** Keywords ***
Custom Locator Strategy 
    [Arguments]    ${browser}    ${criteria}    ${tag}    ${constraints}
    ${retVal}=    Execute Javascript    return
window.document.getElementById('${criteria}');      
    [Return]    ${retVal}
${el}=     Run Keyword If  '${locator}'!='my_checkbox'    My Custom Locator   ${criteria}    ${tag}    ${constraints}

You can get the variable before executing ${el}.checked = true;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!