java - How to use swipe function using selenium -


i have swipe through articles using article id, after every 4 articles swipe there 1 ad, how can manage it. , have print name of article too. used following code

    ...     system.out.println(driver.manage().window().getsize().getwidth());     system.out.println(driver.manage().window().getsize().getheight());      int screenwidth = driver.manage().window().getsize().getwidth();     int screenheight = driver.manage().window().getsize().getheight();     try {         element = driver.findelements(by.id("templeconnect.com.templeconnect:id/templetitle"));     } catch (nosuchelementexception e) {         system.out.println("no such element");     }      //swipe     startx = screenwidth / 2;     endx = screenwidth / 2;     starty = screenheight * 6 / 7;     endy = screenheight / 7;     driver.swipe(startx, starty, endx, endy, 2000);     thread.sleep(3000);     myfun(element);  }  public void myfun(list<webelement> element) {     try {         system.out.println(element.size());         (webelement webelement : element) {             system.out.println(webelement.gettext());             if (webelement.gettext().equals("")) {             } else {                 driver.swipe(startx, starty, endx, endy, 2000);                 thread.sleep(3000);                 myfun(element);             }         }     } catch (nosuchelementexception e) {         system.out.println("no such element funtion");     } catch (interruptedexception e) {         // todo auto-generated catch block         e.printstacktrace();     } }  public void myfun1(list<webelement> element1) throws interruptedexception {     (webelement webelement1 : element1) {         system.out.println(webelement1.gettext());         if (webelement1.gettext().equals("explore more")) {             driver.swipe(startx, starty, endx, endy, 2000);         }     } } 


Comments