Reusable pageSource

when doing any requests with driver.findElement() or element.getText(), etc. I suppose new getPageSource() is being called. Is that correct?

What I want to ask is, is there any way to use the same pageSource for next calls? In case when I have a static content, doing nothing but to read element’s labels - I want to save time not calling pageSource all over again, but use the same one (because i know, nothing on the screen changed).

Would be great to have a feature, e.g.:

 //Do the reading
 //Do some other actions that will actually change structure of the pageSource

I don’t know, this might not be possible. Enlighten me, please :bulb:

Any thoughts about that?

You should create String variable and then set value of String variable as getPageSource(). If you want to find element in page source without any request, you can parse into the String variable’s value.

Ohh ok… I know what you mean. That’s one way to create a custom parser and parse it out myself. :+1:
Same thing could be implemented for general use in Appium/Selenium.

The page source only needs to be (re)built when xpath location is used or pageSource itself is called. Otherwise this is not necessary