Reputation: 21
I use robotframework + appium, recently i set automationName to UiAutomator2, i found UI automation test case run fast, but unfortunately, some keywords not work, like page should contain element, i use like this:
${status} | Run Keyword And Return Status | Page Should Contain Element | &{locator_login_link}[${PLATFORM}]
Run Keyword If ‘${status}’==‘True’ Run Keywords Click Element &{locator_edit_profile_icon}[${PLATFORM}]
but can’t capture the element &{locator_login_link}[${PLATFORM}]
even though show the element on phone, then i change ‘page should contain element’ to ‘wait until element is visible’, then it works!
BYI, must add ‘wait until element is visible’ before every ‘click element’ otherwise will failed, is UiAutomator2 not support well for appiumlibray in robotframework?
Upvotes: 0
Views: 602
Reputation: 329
Alternatively you can create a common set of keywords in a resource file like common.robot. Such as .....
Click Element When Visible
[Arguments] ${element}
Wait Until Element Is Visible ${element}
Click Element ${element}
Get Element Text When Visible
[Arguments] ${element}
Wait Until Element Is Visible ${element}
${txt}= Get Text ${element}
[Return] ${txt}
And then just use these when you need to click an element or get text etc...
Upvotes: 0
Reputation: 367
BYI, must add ‘wait until element is visible’ before every ‘click element’ otherwise will failed
You don't have to explicitly call that wait. What you should be able to do override 'click element' method (or change it) to call 'wait until element is visible' before every click.
I really recommend this approach as it will make your UI tests a lot more stable. Explicit wait should be called before all UI interactions performed by webdriver.
Upvotes: 0