I am using Robot Framework and Appium to automate an Android native app. We have moved to espresso driver for running these tests and the elements need to be identified using the view-tag locator. However, Appium Robot library does not have support for this locator strategy. I have written the custom keyword below
from robot.libraries.BuiltIn import BuiltIn
from robot.api.deco import keyword
@keyword(name='Find by ViewTag')
def by_viewtag(tagname):
"""Provides support to find elements using view tag for Espresso driver on Android"""
appiumlib = BuiltIn().get_library_instance('AppiumLibrary')
driver = appiumlib._current_application()
el = driver.find_element_by_android_viewtag(tagname)
print(el)
return el
and I am using it in my page file to find the object like this:
*** Settings ***
Library ../../../../Resources/Utils/find_elements_utils.py
Library BuiltIn
Library AppiumLibrary
Resource ../../../../Resources/Utils/helpers.robot
*** Variables ***
${loginBtn} = id=btn_sign_in
${signUpEmail}= Call Method Find by ViewTag
However, running this throws the following error
Element locator 'Call Method Find by ViewTag' did not match any elements after 20 seconds
Robot framework thinks I am passing an element locator when I am trying to call a keyword to find the locator. Can someone please help me with this? Is there any additional function I need to write to make this happen?
Please help!