Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

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

Open
yahyakara opened this issue Oct 8, 2022 · 2 comments
Open

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

yahyakara opened this issue Oct 8, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@yahyakara
Copy link

yahyakara commented Oct 8, 2022

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.

@igortavtib
Copy link
Owner

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 igortavtib added the enhancement New feature or request label Nov 7, 2022
@emasmirza03
Copy link

emasmirza03 commented Sep 13, 2023

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants