appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.2k stars 753 forks source link

[Bug] [PageObject] AppiumDriver.findElement() called twice #2034

Open jiangyitao opened 10 months ago

jiangyitao commented 10 months ago
appium@2.1.3 
uiautomator2@2.29.9
java-client v8.5.1 / v8.6.0
class HomePage {

    @AndroidFindBy(accessibility = "Not Exists")
    WebElement loginBtn;

    HomePage(AppiumDriver driver) {
        // Timeout is Duration.ZERO or Duration.ofMillis(-1)
        PageFactory.initElements(new AppiumFieldDecorator(driver, Duration.ZERO), this);
    }

    void clickLoginBtn() {
        loginBtn.click();
    }
}

// Timeout is Duration.ZERO, but "/session/{sessionId}/element" called twice
new HomePage(driver).clickLoginBtn()
2023-10-09 22:44:36:292 - [HTTP] [HTTP] --> POST /session/6591db71-fb19-4037-861e-07c8f9d63252/element
2023-10-09 22:44:36:292 - [HTTP] [HTTP] {"using":"accessibility id","value":"Not Exists"}
2023-10-09 22:44:36:536 - [AndroidUiautomator2Driver@03be (6591db71)] Got response with status 404: {"sessionId":"2d2feb89-50bf-42e1-b196-b2c23e4f7a45","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:63)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:277)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:271)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.chann...
2023-10-09 22:44:36:543 - [HTTP] [HTTP] <-- POST /session/6591db71-fb19-4037-861e-07c8f9d63252/element 404 251 ms - 815
2023-10-09 22:44:36:543 - [HTTP] [HTTP] 
2023-10-09 22:44:37:057 - [HTTP] [HTTP] --> POST /session/6591db71-fb19-4037-861e-07c8f9d63252/element
2023-10-09 22:44:37:057 - [HTTP] [HTTP] {"using":"accessibility id","value":"Not Exists"}
2023-10-09 22:44:37:309 - [AndroidUiautomator2Driver@03be (6591db71)] Got response with status 404: {"sessionId":"2d2feb89-50bf-42e1-b196-b2c23e4f7a45","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:63)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:277)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:271)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.chann...
2023-10-09 22:44:37:311 - [HTTP] [HTTP] <-- POST /session/6591db71-fb19-4037-861e-07c8f9d63252/element 404 255 ms - 815