Appium:settings 设置

参考链接

settings

Settings are a new concept introduced by appium. They are currently not a part of the Mobile JSON Wire Protocol, or the Webdriver spec.

Settings are a way to specify the behavior of the appium server.

Settings are:

  • Mutable, they can be changed during a session
  • Only relevant during the session they are applied. They are reset for each new session.
  • Control the way the appium server behaves during test automation. They do not apply to controlling the app or device under test.

被测试的页面是动态的,一直在更新,比如企业微信打卡界面,一直有个时间的“ : ”在闪动,如下:

这时 Appium Server 认为这个页面还没有加载完,不会去发送指令到手机端,它会等待页面完全加载完成,再发送命令,这个等待的时长默认是 10s 。

这个日志可以在 adb logcat 中获取到,如下:

04-28 17:27:08.071  8665  8686 I appium  : channel read invoked!
04-28 17:27:08.071  8665  8686 I appium  : channel read: POST /wd/hub/session/5cd46f46-027d-45cc-b15b-31e58e80b125/elements
04-28 17:27:08.073  8665  8686 I appium  : Find elements command using 'xpath' with selector '//*[contains(@text,'更新')]'.
04-28 17:27:08.073  8665  8686 I appium  : Waiting up to 10000ms for device to be idle
04-28 17:27:08.709  8699  8699 W wework  : [8699:0428/17:27:08.709:W:com_tencent_wework_foundation_logic_AttendanceService.cpp(1203)] nativeGetOutsideCheckinLocation

所以,如果页面一直处于不断刷新的状态,appium Server 会一直等待,直到 10s 结束 ,才开始进行指令的发送。这时我们可以主动的将这个时间设置短一点,如下:

caps['settings[waitForIdleTimeout]'] = 0

设置 settings 里面的 waitForIdleTimeout 这个参数为 0,无论页面是动态还是非动态都会直接发送请求,而不需要任何等待。这样完美提升了测试的运行速度。

1 Like
关闭