-
Notifications
You must be signed in to change notification settings - Fork 163
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
Fix getText() to work with elements outside viewport #327
Conversation
It's an expected behavior https://www.w3.org/TR/webdriver/#get-element-text I don't think it's a responsibility of this package. You just need to make sure that text is in a viewport (same as your user) |
For W3C driver conformant yes, but not for general element itself. As discussed in the PR desc, |
The Selenium Server (used by this driver) only operates page elements, that the user can see. For that reason, there can't be a Mink/Behat test, that tests parts of the page, invisible to the user. Because of the above fact, Selenium Server API doesn't have a method to retrieve HTML of an element (user can't see it on the page anywhere) and we have to develop a JavaScript-based solution, which doesn't respect element visibility as you've noticed. There are no tests for I'm not certain what direction we should take with this:
// @stof Related PR: #328 |
@aik099 Thank you for getting into it. I strongly belive we should go with the 1st option because: a) some browsers like Firefox operate on invisible elements, some browsers like Chrome does not (and only in some modes, like |
@mvorisek , the case you're facing (website doesn't fit in a small browser window and therefore it looks like the user isn't seeing the text) is expected behavior. How you can hope to pass the test when text is invisible to the user? P.S. |
@aik099 I think of it this way - DOM has no viewport, if a DOM element is queried for a text with |
@mvorisek I think you're not using the right tool for the job. Selenium is for user testing. You should not be interacting with or making assertions against anything that the user cannot interact with or see. You'll notice this being enforced as the Selenium server has evolved. In older versions, you used to be able to click elements that were covered by other elements, but with newer versions, you will now get an exception. If a user cannot do it, then Selenium won't allow you to do it either. |
Closing then. |
Original impl. using
$element->text()
is defined as "Returns the visible text for the element." [1].This PR fixes the implementation to make
getText()
working with elements outside viewport. The new impl. is inspired bygetHtml()
method defined a few lines below. Thus this fix should be consistent and there should be no downside.See atk4/ui#1538 - when small window (like 1280x720) is given, the tests fail with the original implementation. With this PR, the issue is fixed.
[1] https://github.com/instaclick/php-webdriver/blob/v1.0.8/lib/WebDriver/Element.php#L33