javascript - scroll within a scrollable element with webdriver-io? -


how scroll within scrollable element webdriver-io? have tried following code:

client .scroll('#hierarchy_p') .scroll(20, 50); 

or

client .scroll('#hierarchy_p', 20, 50); 

but neither of them have effect.

normally, wouln't advice using driver.executescript, until webelement.setattribute comes up, doubt there many other ways of doing this.

for scrolling , down scrollable element:

function scrolltofn(driver, element, scrollamount){     return elem.getattribute('scrolltop').then(function(val){         scrollamount += +val;       // written +val string number conversion         return driver.executescript("arguments[0].scrolltop = arguments[1]", elem, scrollamount);     }); } 

for scrolling particular element inside scrollable element:

function scrolltoinnerfn(driver, parentele, innerele){     return innerele.getattribute('offsettop').then(function(val){         return driver.executescript("arguments[0].scrolltop = arguments[1]", parentele, val);     }); } 

note: both above functions returning promise.

usage

... var webdriver = require('selenium-webdriver'); var browser1 = new webdriver.builder().usingserver().withcapabilities({     browsername: 'firefox' }).build(); ...  var elem = browser1.findelement(webdriver.by.css('#scrollt')); var elem2 = browser1.findelement(webdriver.by.css('#mm')); scrolltofn(browser1, elem, 200).then(function(){     scrolltoinnerfn(browser1, elem, elem2); }).then(... 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -