I’m trying to figure out how to use custom locators. It seems to work for locating elements, but if I use a keyword such as Wait Until Page Contains Element, it fails immediately without waiting for the requested timeout.
My custom locator is: Get Element By Data-TestID [Arguments] ${browser} ${locator} ${tag} ${constraints} ${e} Get WebElement //*[@data-testid="${locator}"] [Return] ${e}
And I’m using it like this: Test Setup Add Location Strategy data-testid Get Element By Data-TestID
Hard to say anything concrete with these details. Could you show the relevant parts where you create the custom selector, use it and snippets of a log with --loglevel trace set from the command line.
*** Settings ***
Test Setup Add Location Strategy data-testid Test Custom Locator
*** Keywords ***
Test Custom Locator
[Arguments] ${browser} ${locator} ${tag} ${constraints}
${e} Get WebElement //*[@data-testid="${locator}"]
[Return] ${e}
*** Test Cases ***
Temp
Start Browser ${PELAdminURL}
set log level trace
Wait Until Page Contains Element //*[@data-testid="45AEE8C1-63D4-4AFD-85B0-BB83FF8170ED"] #this works
Click Element data-testid:45AEE8C1-63D4-4AFD-85B0-BB83FF8170ED #this works
Wait Until Page Contains Element data-testid:testtesttest timeout=90 #this should fail after 90 seconds
#####################################################################
Please try to put Sleep function before Wait Until Page. Example:
Wait Until Page Contains Element //*[@data-testid=“45AEE8C1-63D4-4AFD-85B0-BB83FF8170ED”] #this works
Click Element data-testid:45AEE8C1-63D4-4AFD-85B0-BB83FF8170ED #this works
Sleep 1
Wait Until Page Contains Element data-testid:testtesttest timeout=90 #this should fail after 90 seconds