appium / appium/java-client

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

Open
#2,034 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.3k
Forks
752
Avg merge
6d 21h
Merged PRs (30d)
8

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal HomePage reproduction and trace PageFactory.initElements through AppiumFieldDecorator, observing the two /session/{sessionId}/element requests. The payload names no source files or tests; done means the failed lookup in HomePage.clickLoginBtn no longer produces duplicate element requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.