I am using Android Hybrid app for testing using Protractor. I want to scroll the page in the app. I am using the ScrollTo or ScrollBy. It's neither scrolling the Page nor giving any error, but its printing the text in the visible page.
Please help.
My Code is below:
browser.executeScript('window.scrollBy(0,100000);').then(function() {
element.all(by.css('.row.qcl-section-header')).getText().then( function(text) {
console.log(text)
});
});
First, use getLocation()
to get the x and y coordinates, then use window.scrollTo()
to scroll:
element.all(by.css('.row.qcl-section-header')).getLocation().then(function(navDivLocation) {
initTop = navDivLocation.y;
initLeft = navDivLocation.x;
browser.executeScript('window.scrollTo(' + initTop + ',' + initLeft + ');').then(function() {
element.all(by.css('.row.qcl-section-header')).getText().then(function(text) {
console.log(text)
});
});
});