Appium's "Get Page Source" command is slow in iOS

Appium's "Get Page Source" command in iOS is used to get the application hierarchy XML.

It sometimes takes several minutes especially when the page source is large.

This is because Apple doesn't provide an API to get the whole element tree, which means Appium needs to get it by calling the Apple's API to get an element recursively.

I think here is the function to get XML from elements recursively:

https://github.com/appium/WebDriverAgent/blob/33a110209035a3017080340dd9b4c75c4997e991/WebDriverAgentLib/Utilities/FBXPath.m#L350

WebDriverAgent is a WebDriver server installed in iOS to communicate with XCUITest driver that enables Appium to communicate with iOS app.

And the writeXmlWithRootElement method here is recursively called to create XML that represents the application hierarchy.

I guess this limit causes the slow query to get the page source. It perhaps takes time in proportion to the number of elements in the page.