GET source of an element

getPageSource says “Get the current page/app source as HTML/XML
GET /session/:sessionId/source

It will be helpful to have a similar endpoint for an element; something like:

GET /session/:sessionId/element/:elementId/source/

It will be useful for cases when the source page is too big, the hierarchy is deeper than 60 layers and it is hard to get the full page source XML.

WDA fails to read the content of pages with deep hierarchy, when we increase the layers setting snapshotMaxDepth higher than for example 65. So it is hard to inspect very deep elements to get their locators and access them in tests.

If we could get the source XML/JSON of an element, we would located very deep elements in two steps. In the first we would get the page source of first 60 layers, then the 20 layers of elements from 60 layer, as result we could locate very deep element in 60+20 level which is almost not possible by page full source.

This is a good idea, but unfortunately it won’t work. XCTest always takes a snapshot from the current application element, which is the actual hierarchy root. This means even if we want to retrieve a snapshot of an element the framework still takes the root snapshot and then “cuts it off” the overall tree

1 Like