[Appium][xcuitest]Compare getting outputs speed of source format

Appium provides useJSONSource capability to make parsing XML in source command faster than the default XML format.

In general, getting page source via Appium (WDA) is slower than XCUIApplication().debugDescription since XDA confirmed and attache some additional properties like visibility. The debug description does not provide visibility in the description.

But, sometimes, the debugDescription helps us to get source when we get the source faster than other way, while it has less properties.

We can get them as below mobile command:

@driver.execute_script 'mobile: source', { format: :json }
# :json, :description, :xml

description format

Output: https://gist.github.com/KazuCocoa/b3f22590d1cb7f6aebf4357753f1db07

(1..5).map do
  before = Time.now
  @driver.execute_script 'mobile: source', { format: :description }
  Time.now - before
end.sum / 5
=> 0.3068634

JSON format

Output: https://gist.github.com/KazuCocoa/2a97b97bab66744d2069ff34680200e4

(1..5).map do
  before = Time.now
  @driver.execute_script 'mobile: source', { format: :xml }
  Time.now - before
end.sum / 5
=> 5.7233082

XML format

Output: https://gist.github.com/KazuCocoa/be0a99211133f2c3f1318689d304415a

(1..5).map do
  before = Time.now
  @driver.execute_script 'mobile: source', { format: :json }
  Time.now - before
end.sum / 5
=> 6.1492987999999995

Target

The test target was Apple news app.

Conclusion

The debugDescription is faster than other way, but it has few attributes which is not enough for Appium. If we can replace it with the official one, we’re exactly happy… 😊

1 Comment

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.