Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyword "Get page source": Add selector for partial source code #3460

Open
simonmeggle opened this issue Mar 1, 2024 · 7 comments
Open

Keyword "Get page source": Add selector for partial source code #3460

simonmeggle opened this issue Mar 1, 2024 · 7 comments
Assignees
Labels
closeable? This issue should be closed? enhancement New feature or request priority: high

Comments

@simonmeggle
Copy link
Contributor

I want to propose to add an optional selector to the keyword Get 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:

Get Page Source  p.availability
<p class="availability narrow">
  <span class="key">Durchschnittliche Erreichbarkeit des Dienstes in den letzten 7 Tagen: </span>
  <span class="value bold">100,00 %</span>
</p>
Get Text  p.availability span.value 
100,00 %

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.

@aaltat
Copy link
Member

aaltat commented Mar 1, 2024

So are you looking what this Playwright API returns https://playwright.dev/docs/api/class-locator in innerHTML ?

@simonmeggle
Copy link
Contributor Author

So are you looking what this Playwright API returns https://playwright.dev/docs/api/class-locator in innerHTML ?

Yes, exactly.

@simonmeggle
Copy link
Contributor Author

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.

@aaltat aaltat added enhancement New feature or request priority: high labels Mar 1, 2024
@aaltat
Copy link
Member

aaltat commented Mar 1, 2024

@allcontributors please add @simonmeggle for ideas

Copy link
Contributor

@aaltat

@simonmeggle already contributed before to ideas

@Snooz82 Snooz82 self-assigned this Oct 6, 2024
@Snooz82 Snooz82 added this to the v18.9.0 milestone Oct 6, 2024
@Snooz82
Copy link
Member

Snooz82 commented Oct 7, 2024

@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?

@Snooz82 Snooz82 added the closeable? This issue should be closed? label Oct 7, 2024
@Snooz82 Snooz82 removed this from the v18.9.0 milestone Oct 7, 2024
@simonmeggle
Copy link
Contributor Author

Ah, nice. Did not know this, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closeable? This issue should be closed? enhancement New feature or request priority: high
Projects
None yet
Development

No branches or pull requests

3 participants