I have an element on the page that I'm testing that I have to scroll down to be visible. When I execute my test, I get Element is not clickable at point (94, 188) for example.
I tried the following:
dvr.executeScript('window.scrollTo(0,250);');
But it didn't work. Does anyone know how this works?
This seems so late to answer you.. But anyways,
The following code helped me to remove the Element is not clickable error.
var elm = element.all(by.css('.your-css-class')).get(9);
browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());
elm.click();
Basically this allows you scroll into your view..
The window.scrollTo(x,x)
solution didn't work for me. Specially when testing against ripple emulator.
I managed to make it work using scrollIntoView
method.
var scrollToScript = 'document.getElementById("ELEMENT ID").scrollIntoView();';
browser.driver.executeScript(scrollToScript).then(function() {
element(by.id('ELEMENT ID')).click();
expect(...);
});
'use strict';
/**
* Vertically scroll top-left corner of the given element (y-direction) into viewport.
* @param scrollToElement element to be scrolled into visible area
*/
function scrollTo(scrollToElement) {
var wd = browser.driver;
return scrollToElement.getLocation().then(function (loc) {
return wd.executeScript('window.scrollTo(0,arguments[0]);', loc.y);
});
};
Usage:
scrollTo(element(by.css("div.someclass")));
Disclaimer: this code is from sg-protractor-tools's scroll.js
.
Code is licensed under the MIT license.
i think this is helpful to you:
dvr.executeScript('window.scrollTo(94,188);').then(function() {
element(by.<<here your button locator>>).click();
})
your webdriver is unable to read that point (1254,21),the reason is your protractor browser unable to cover the full of page what do you want to test, then we give a command that browser is scroll to that point (1254,21), then perform the click operation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With