Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #389 +/- ##
============================================
- Coverage 89.42% 89.08% -0.34%
- Complexity 184 185 +1
============================================
Files 1 1
Lines 501 504 +3
============================================
+ Hits 448 449 +1
- Misses 53 55 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| { | ||
| $this->executeJsOnElement( | ||
| $element, | ||
| "arguments[0].scrollIntoView({ behavior: 'instant', block: 'end', inline: 'nearest' });" |
There was a problem hiding this comment.
shouldn't we use nearest as well in the block direction ?
There was a problem hiding this comment.
I don't use the scrollIntoView method myself. I've only copied the whole line from the PHP WebDriver (see https://github.com/php-webdriver/php-webdriver/blob/11923b4ba312fc9d137266ae67438be65d4d500f/lib/Remote/RemoteWebElement.php#L249 ). I trust that they know what's right here.
There was a problem hiding this comment.
@stof, my point here is still valid. I think this driver should scroll to an element exactly the same as the underlying facebook web driver does for webdriver-classic-driver driver.
There was a problem hiding this comment.
You were right that something was off. The WebDriver spec's "scroll into view" (used by Element Click) uses exactly block: "end", inline: "nearest", but "only if the element is not already in view". php-webdriver kept the options and dropped that condition, and I copied php-webdriver.
I tried it in a browser with a fixed footer at the bottom of the page. Always scrolling with block: 'end' moves an element that's already visible on a scrolled page down under the footer, so the click hits the footer. With the condition, visible elements don't move, and elements outside the viewport still scroll like end.
block: 'nearest' would fix that case too; it only differs for elements above the viewport (they end up at the top edge instead of the bottom). I went with the spec instead, so the driver keeps scrolling like a WebDriver click does: an element that's fully inside the viewport isn't scrolled, otherwise block: 'end' is used as before. It's still a single script call.
b6823ea to
a65aa40
Compare
|
Not merging yet, because I think we need to add a missing test in driver-testsuite. |
a65aa40 to
65652da
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f791356 to
dce2e87
Compare
Using the
movetoWebDriver command the Firefox will trigger an\WebDriver\Exception\MoveTargetOutOfBoundsexception when the element is outside of the viewport:The
movetocommand is used in these driver methods:clickOnElementclick(doesclickOnElementinternally)check(doesclickOnElementinternally)uncheck(doesclickOnElementinternally)setValue(checkboxes only; doesclickOnElementinternally)mouseOverrightClick(doesmouseOverinternally)doubleClick(doesmouseOverinternally).
The test suite isn't testing mouse-related operations (listed above) outside of the viewport.
P.S.
movetoautomatically adjusts the viewport.