javascript - Selenium Java Scroll Bar in section -
im trying move scroll bar right using selenium webdriver in java, in order focus on element screenshot, after trying know, cannot it.
the scenario shown on picture 1: sorry deleting data due privacy issues
as may see, scroll located element in blue rectangle,
i've tried one:
javascriptexecutor js; js = (javascriptexecutor) driver; js.executescript("$(\"#pagination\").animate({ scrollleft: \"-50000px\" })"); pagination div id.
can me guys?
best regards.
use 'openqa.selenium.interactions.actions' move element. should automatically element's position x, y , scroll it.
// initialize instance actions action = new actions(webdriver); // find element focus inside iframe webelement = webdriver.findelement("<find element wish focus>"); // perform move action action.movetoelement(we).build().perform(); haven't tested though, hope helps.
update:
you have 2 similar ids - "#pagination" , "#paginacion". confusing.
also, should consider adding class rows have data, data-row.
note: sure correctly find element. displaying table data, element table cell, not table itself.
1) in java code store script string variable:
string script = "return $('#paginacion').find('.data-row').eq(%1$d - 1).find('td').eq(%2$d - 1)"; 2) pass rownumber , columnnumber executescript method.
note: should add null checks.
int rownumber = 1; int columnnumber = 19; list<webelement> webelements = (list<webelement>)js.executescript(string.format(script, rownumber, columnnumber)); 3) when element found, call movetoelement method
action.movetoelement((webelement) webelements.get(0)).build().perform(); tested , works.
Comments
Post a Comment