python-client icon indicating copy to clipboard operation
python-client copied to clipboard

bug: Unable to timeout `find_elements` and `webdriver.Remote`

Open eyJhb opened this issue 2 years ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

Sometimes webdriver.Remote will hang, and it will timeout at any point. The same goes for using find_elements, if WDA crashes/hangs, then it will never timeout.

I've tried setting appium:newCommandTimeout to 5, but it will still just hang forever. The only thing I've found that worked, was sitting driver.command_executor.keep_alive = False and driver.command_executor.set_timeout(5).

It's quite unclear, what the best/correct way, is to set a timeout for "anything" so that it cannot just hang indefinitely.

Expected Behavior

That it would timeout after 5 seconds, and there would be a clear documented way of doing this.

Minimal Reproducible Example

from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy

ios_caps = {
    "appium:automationName": "XCUITest",
    "platformName": "iOS",
    "appium:udid": "00008020-001655400E82002E",
    "appium:webDriverAgentUrl": "http://localhost:7777",
    "appium:newCommandTimeout": 5,
}

driver = webdriver.Remote("http://127.0.0.1:4723", ios_caps)
driver.command_executor.set_timeout(5)
driver.find_elements(by=AppiumBy.IOS_PREDICATE, value="type LIKE '**'")

The find_elements in a slow app (ie. TikTok) will never return.

Environment

  • Operating system:
  • If running via appium CLI...
    • Appium CLI version (output of appium --version): 2.0.0-beta.58
    • Node.js version (output of node --version): v18.12.1
    • npm version (output of npm --version): 8.19.2
    • Last appium version which did not exhibit the problem: ?
  • If running Appium Desktop, its version:
  • Appium driver(s) and their version(s): - [email protected] [installed (npm)]
  • Appium plugin(s) and their version(s): go-ios (gist attached later)
  • Platform and version under test: iOS 16.4.1
  • Real device or emulator/simulator: real device

Link to Appium Logs

No response

Futher Information

No response

eyJhb avatar Apr 26 '23 12:04 eyJhb

@mykola-mokhnach is there a way to do this for other clients?

eyJhb avatar Apr 27 '23 06:04 eyJhb

I don't know. xcuitest driver has the appium:commandTimeouts capability, which might be helpful in such situation

mykola-mokhnach avatar Apr 27 '23 06:04 mykola-mokhnach

Based on the default value of that, it doesn't work. I've had tests hang for hours, and the default value specifies 120s. Most of the time, the case is that the WDA server becomes unresponsive, and Appium will just hang forever waiting for a response.

eyJhb avatar Apr 27 '23 08:04 eyJhb