jonhoo / fantoccini

A high-level API for programmatically interacting with web pages through WebDriver.
Apache License 2.0
1.68k stars 125 forks source link

Test whether text is visible? #203

Closed Ekleog closed 1 year ago

Ekleog commented 1 year ago

Hey! I'm looking into fantoccini as a way of testing my yew ui, and am wondering how to test whether some text is visible.

For instance, I have a banner that slides off-screen when not being displayed and just stays there because it's much easier than trying to remove the element from the dom with yew.

AFAICT, fantoccini would catch this banner text even when it is off-screen, thus not allowing me to test whether it's actually going up and down properly. It also seems pretty hard to actually do it, especially as even this solution seems to me like it just checks whether at least one pixel of all parent elements is displayed, and not whether the text itself is actually displayed.

Is such tooling in-scope for fantoccini, or is it out-of-scope, and in the second case would you happen to know of a project for which it would be in-scope (or even would already be implemented)?

Anyway, fantoccini looks like a great crate from afar, though I have not had a chance to try it yet!

jonhoo commented 1 year ago

If it's not directly supported by the webdriver protocol, then this does feel a little above fantoccini's domain. It's more something @stevepryde's thirtyfour crate might provide on top of WebDriver. Let's see what Steve says!

stevepryde commented 1 year ago

@Ekleog as you mentioned, checking for element visibility is quite challenging. I don't think there's any native way to do this using webdriver.

You could maybe try to come up with some JavaScript that would do it, and then execute that as a script on the page.

If you do find a solution that works, I'd be happy to add it in thirtyfour.

Ekleog commented 1 year ago

Got it, thank you!