java - Only first elements are visible in list -


i have list of webelements in webpage specific height-width (that don't know), , want print elements shown in list. here code:

public cinemamodule cinemasname() throws interruptedexception {     list<webelement> cinemalist = driver.findelements(by.cssselector("h4.media-heading"));     system.out.println("total cinemas " + cinemalist.size());     system.out.println("cinemas names are:- ");     (int = 0; < cinemalist.size(); i++)     {         system.out.println(cinemalist.get(i).gettext());         return new cinemamodule(driver);     } } 

this code gives me count = 32 when text prints first 4 cinemas text (that viewable) , rest of cinemas prints null (no text) because rest of cinemas list under scrolling. viewing cinemas name (webelement) have scroll.

how print list of 32 cinemas?

you can use javascriptexecuter's executescript() method scroll particular element view , use gettext() method obtains text element.

try below code,

public cinemamodule cinemasname() throws interruptedexception {     list<webelement> cinemas = driver.findelements(by.cssselector("h4.media-heading"));     system.out.println("total cinemas " + cinemas.size());     system.out.println("cinemas names are:- ");     javascriptexecutor jse = (javascriptexecutor) driver;     (webelement cinema : cinemas)     {         jse.executescript("arguments[0].scrollintoview(true);", cinema);         system.out.println("  " + cinema.gettext());     }      return new cinemamodule(driver); } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -