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

[Help Request] How can we user Appium switch context function

Open yahyakara opened this issue 3 years ago • 2 comments

Hi all, I need to use switch flutter driver to UiAutomator2, Is it possible with this library ? It would be very helpfull for hybrid applications and using ui automator 2 functions . Also we can support our tests with Ocr library with uiautomator2.

yahyakara avatar Oct 08 '22 09:10 yahyakara

Well, We are looking for the implementation of a switch context keyword. Even if we can't we will add and execute script keyword to handle scripts from other drivers

igortavtib avatar Nov 07 '22 21: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