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

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -