Reputation: 670
I am new to protractor e2e test. I need to scroll on a map using protractor and select any location on it. I didnt find any way of automatically performing scroll on map section on internet so i am asking it on this forum.
<map-edit-panel poi-icons="inactive" zoombarrier="16.5" class="full-map-image" mode="location" show-editor="true" filter="NVT_LINK" show-zoom="true" id="mapContainer"><!-- ngIf: showZoom --><div ng-if="showZoom" class="map-ui-right-center ng-scope">
<div ng-click="geoLocate()" class="map-ui-zoom-control map-ui-geolocate"></div>
<div ng-click="zoomIn()" class="map-ui-zoom-control map-ui-zoom-control-up"></div>
<div ng-click="zoomOut()" class="map-ui-zoom-control map-ui-zoom-control-down"></div>
This is the code for the Map section and I need to perform automated scroll up/down to it. Please share your valuable ideas.
Upvotes: 1
Views: 16210
Reputation: 645
1)Scroll Up
browser.executeScript('window.scrollTo(0,0);').then(function(){
console.log('++++++SCROLLED UP+++++');
});
2)Scroll Down
browser.executeScript('window.scrollTo(0,10000);').then(function () {
console.log('++++++SCROLLED Down+++++');
});
3) Scroll to Particular WebElement
var we =GUtils.$element(GUtils.$locatorXpath('xpath'));
browser.executeScript("arguments[0].scrollIntoView();", we.getWebElement()).then(function(){
we.click();
});
Upvotes: 6