Repository navigation
[Bug] [PageObject] AppiumDriver.findElement() called twice #2034
Copy link
Copy link
Closed
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 - 815Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
theluckystrike commentedon Oct 8, 2026
Confirmed on java-client 11.0.0 and fixed in #2472. I ran the page object from this issue against a local HTTP endpoint that records requests and answers
no such element. Eachclick()sent 2POST /elementcalls forDuration.ZEROand forDuration.ofMillis(-1), and a directdriver.findElement()sent 1.The second call comes from
pagefactory.bys.builder.ByChained.findElement(). Every mobile annotation field resolves throughByChained, also with a single annotation, and it wrapped the lookup innew FluentWait<>(context)with the default 500 ms timeout and interval. That wait ran inside the oneAppiumElementLocatoralready runs with the decorator timeout, which isn't visible to the user, so every attempt cost two lookups and at least 500 ms. With #2472 the chain runs once per attempt and the endpoint sees 1 call per click.