Open simonmeggle opened 7 months ago
So are you looking what this Playwright API returns https://playwright.dev/docs/api/class-locator in innerHTML ?
So are you looking what this Playwright API returns https://playwright.dev/docs/api/class-locator in innerHTML ?
Yes, exactly.
And lastly, when you want to assert a certain content in the page source, you normally know where it should roughly be. No need to search the complete DOM or even worse, dump it in case of a failure. This is where a selector also would help.
@allcontributors please add @simonmeggle for ideas
@aaltat
@simonmeggle already contributed before to ideas
@simonmeggle
With Get Property
you can just do that.
Get Property <selector> innerHTML
This just includes the content of an element.
Get Property <selector> outerHTML
This includes the element itself.
I think Get Page Source
is really the wrong keyword for that.
It literally says in the name Page
source. not element.
So maybe we could add a new keyword for innerHTML and outerHTML so that it is more obvious for users. On the other hand, where do we stop?
Ah, nice. Did not know this, thanks!
I want to propose to add an optional
selector
to the keywordGet Page Source
. The current implementation only supports to get the complete page source which can be a huge amount of data.Long use case description: The idea for a selector came when I was trying to find a selector for
Get Text
keyword.My current way is to F12 into the browser devtools, pick the element and then inspect where I could start to locate. As long as the selector is pure XPath/CSS, I develop the selector in the console wia
$x()
or$$()
.The conveniance feature of Browserlib to concatenate Xpath and CSS with
>>
, as well as frame selectors (>>>
) comes at the cost to built them via the Debug Console of VS code, because the browser console does not understand this syntax. That requires to switch between VS Code and the Browser Devtools multiple times (or to work with tiled windows...)It would relly help to do something like this:
Here, I used
Get Page Source
to get a HTML snippet as output right into the debug console of VS Code. From there I can inspect the interesting HTML source code easily and go on to refine the selector - without switching back to the browser.