robotframework-appiumflutterlibrary icon indicating copy to clipboard operation
robotframework-appiumflutterlibrary copied to clipboard

Could we interact with Xpath?

Open edwardPham6868 opened this issue 3 years ago • 2 comments

I have to testing with old Flutter app, developers are not supported, element may not have ValueKey, Text... So is there a way to interact with Xpath ?

edwardPham6868 avatar Nov 01 '22 11:11 edwardPham6868

Currently we have not a xpath locator, we are looking for ways to implement this locator using flutter driver

igortavtib avatar Nov 07 '22 20:11 igortavtib

I add some code in appiumflutter library

_applicationmanagement.py

def switch_to_context(self, context_name):
        """Switch to a new context"""
        self._current_application().switch_to.context(context_name)

_element.py

from appium.webdriver.common.appiumby import AppiumBy

    def click_element_by_xpath(self, locator):
        self._current_application().find_element(AppiumBy.XPATH, locator).click()

    def click_element_by_Id(self, locator):
        self._current_application().find_element(AppiumBy.ID, locator).click()

    def input_text_by_xpath(self, locator, text):
        self._current_application().find_element(AppiumBy.XPATH, locator).send_keys(text)

then on your robot file

 Switch To Context    NATIVE_APP
 Click Element By ID    com.google.android.documentsui:id/thumbnail
 Click Element By Xpath        //android.widget.LinearLayout[@index="1"]/android.widget.RelativeLayout/android.widget.FrameLayout[@resource-id="com.google.android.documentsui:id/thumbnail"]
 Switch To Context    FLUTTER

emasmirza03 avatar Sep 13 '23 03:09 emasmirza03