WebElement Electronics=driver.findElement(By.xpath("//li[@data-key='electronics']"));
Actions act=new Actions(driver);
act.moveToElement(Electronics).build().perform();
WebElement SamsungBrands=driver.findElement(By.xpath("//a[@data-tracking-id='0_Samsung']"));
Thread.sleep(5000);
act.moveToElement(SamsungBrands).click().build().perform();
Thread.sleep(5000);
JavascriptExecutor js=((JavascriptExecutor)driver);
WebElement scroll=driver.findElement(By.xpath("//div[@id='show-more-results']"));
while(!scroll.isDisplayed())
{ js.executeScript("window.scrollBy(0,800)", "");
Thread.sleep(5000); }
//js.executeScript("window.scrollBy(20000,0)", "");
File fExcel=new File("\\C:\\Mobile.xls");
WritableWorkbook wbook=jxl.Workbook.createWorkbook(fExcel);
wbook.createSheet("Samsung_Models", 0);
WritableSheet Writable=wbook.getSheet(0);
Label C1Name=new Label(0,0, "MOBILE MODELS");
Writable.addCell(C1Name);
Label C2Name=new Label(2,0, "OFFER PRICE");
Writable.addCell(C2Name);
int i=1;
List<WebElement> AllModelNames=driver.findElements(By.xpath("//div[@class='pu-title fk-font-13']"));
List<WebElement> Price=driver.findElements(By.xpath("//div[@class='pu-final']"));
int TotalItems=AllModelNames.size();
Iterator<WebElement> itr = AllModelNames.iterator();
Iterator<WebElement> itr1 = Price.iterator();
while(itr.hasNext() || itr1.hasNext() )
{ String Model=itr.next().getText();
Label data1=new Label(0,i,Model);
Writable.addCell(data1);
String Pric=itr1.next().getText();
Label data2=new Label(1,i,Pric);
Writable.addCell(data2);
i=i+1; }
driver.close();
wbook.write();
wbook.close();
}
}
List<String> result = new ArrayList<String>();
for (String next : file) {
if (next != null && next.length() != 0) result.add(next);
}
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fe95de11-2fa1-41db-a79b-afcff47fd980%40googlegroups.com.