Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get method getInstance from class androidx.test.uiautomator.Gestures with parameter types [class androidx.test.uiautomator.UiDevice] #592

Closed
Comeodore opened this issue Jan 2, 2024 · 2 comments

Comments

@Comeodore
Copy link

Comeodore commented Jan 2, 2024

With new master i have next issue when try click on element, 2.3.0 beta01 uiautomator

appium/appium#19597

external_services/appium_driver/driver.py:614: in click
    element.click()
venv/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py:94: in click
    self._execute(Command.CLICK_ELEMENT)
venv/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py:395: in _execute
    return self._parent.execute(command, params)
venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py:348: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <appium.webdriver.errorhandler.MobileErrorHandler object at 0x29d5c3e50>
response = {'status': 500, 'value': '{"value":{"error":"unknown error","message":"An unknown server-side error occurred while pro...:2081)\\n\\tat io.appium.uiautomator2.utils.ReflectionUtils.getMethod(ReflectionUtils.java:93)\\n\\t... 38 more\\n"}}'}

    def check_response(self, response: Dict[str, Any]) -> None:
        """
        https://www.w3.org/TR/webdriver/#errors
        """
        payload = response.get('value', '')
        if isinstance(payload, dict):
            payload_dict = payload
        else:
            try:
                payload_dict = json.loads(payload)
            except (json.JSONDecodeError, TypeError):
                return
            if not isinstance(payload_dict, dict):
                return
        value = payload_dict.get('value')
        if not isinstance(value, dict):
            return
        error = value.get('error')
        if not error:
            return
    
        message = value.get('message', error)
        stacktrace = value.get('stacktrace', '')
        # In theory, we should also be checking HTTP status codes.
        # Java client, for example, prints a warning if the actual `error`
        # value does not match to the response's HTTP status code.
        exception_class: Type[sel_exceptions.WebDriverException] = ERROR_TO_EXC_MAPPING.get(
            error, sel_exceptions.WebDriverException
        )
        if exception_class is sel_exceptions.WebDriverException and message:
            if message == 'No such context found.':
                exception_class = appium_exceptions.NoSuchContextException
            elif message == 'That command could not be executed in the current context.':
                exception_class = appium_exceptions.InvalidSwitchToTargetException
    
        if exception_class is sel_exceptions.UnexpectedAlertPresentException:
            raise sel_exceptions.UnexpectedAlertPresentException(
                msg=message,
                stacktrace=format_stacktrace(stacktrace),
                alert_text=value.get('data'),
            )
>       raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
E       selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot get method getInstance from class androidx.test.uiautomator.Gestures with parameter types [class androidx.test.uiautomator.UiDevice]
E       Stacktrace:
E       io.appium.uiautomator2.common.exceptions.UiAutomator2Exception: Cannot get method getInstance from class androidx.test.uiautomator.Gestures with parameter types [class androidx.test.uiautomator.UiDevice]
E       	at io.appium.uiautomator2.utils.ReflectionUtils.getMethod(ReflectionUtils.java:97)
E       	at io.appium.uiautomator2.model.internal.CustomUiDevice.getGestureController(CustomUiDevice.java:159)
E       	at io.appium.uiautomator2.core.AxNodeInfoHelper.click(AxNodeInfoHelper.java:131)
E       	at io.appium.uiautomator2.model.BaseElement.click(BaseElement.java:70)
E       	at io.appium.uiautomator2.handler.Click.safeHandle(Click.java:37)
E       	at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)
E       	at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:277)
E       	at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:271)
E       	at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:77)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
E       	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
E       	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
E       	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
E       	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
E       	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
E       	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
E       	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
E       	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
E       	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
E       	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
E       	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
E       	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
E       	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
E       	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
E       	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
E       	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)
E       	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)
E       	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
E       	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
E       	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
E       	at java.lang.Thread.run(Thread.java:1012)
E       Caused by: java.lang.NoSuchMethodException: androidx.test.uiautomator.Gestures.getInstance [class androidx.test.uiautomator.UiDevice]
E       	at java.lang.Class.getMethod(Class.java:2103)
E       	at java.lang.Class.getDeclaredMethod(Class.java:2081)
E       	at io.appium.uiautomator2.utils.ReflectionUtils.getMethod(ReflectionUtils.java:93)
E       	... 38 more

@KazuCocoa @mykola-mokhnach

@mykola-mokhnach
Copy link
Contributor

This is expected. Google did some breaking changes there and the server code must be updated in order to be compatible with them.
You may try to play with this draft for now: #591

@KazuCocoa
Copy link
Member

UIA2 driver 2.38.0 has the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants