I am automating a process a process where I need to download csv files from a website.
I have written a jquery code for that. Can someone tell me how can i integrate this code with my Java selenium code.
a.java
package package1;
import java.text.ParseException;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.seleniumhq.jetty9.util.log.Log;
public class Noofrowsandcols {
public static void main(String[] args) throws ParseException, InterruptedException {
WebDriver wd;
String exepath="C:\\Users\\sh370472\\Downloads\\chromedriver_win32 (2)\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", exepath);
wd= new ChromeDriver();
wd.get("https://www.shipper-ml.com");
wd.findElement(By.id("inpUserId")).sendKeys("xxxxxxxx");
wd.findElement(By.id("inpPassword")).sendKeys("xxxxxxxxxxxxxx");
wd.findElement(By.id("btnLogonLabel")).click();
Thread.sleep(1000);
wd.get("https://www.shipper-ml.com/viewReports.do");
}
}
b.js
$(document).ready(function () {
$(window).load(function () {
$('.ibody tr').each(function (a, b) {
var count=0;
var name = $('.cl', b).text();
if(name.indexOf(".CSV")!==-1 && name.indexOf("TAS")!==-1){
var d= a-9;
var hiddenIFrameID = 'hiddenDownloader' + count++;
var iframe = window.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
window.body.appendChild(iframe);
iframe.src = "https://www.shipper-ml.com/viewReports.do?
ctrl=reportListForDownload&action=DownloadReport¶m="+d;
}
});
}); });
JavascriptExecutor js = (JavascriptExecutor) wd;
js.executeScript("$(document).ready(function () {
$(window).load(function () {
$('.ibody tr').each(function (a, b) {
var count=0;
var name = $('.cl', b).text();
if(name.indexOf(".CSV")!==-1 && name.indexOf("TAS")!==-1){
var d= a-9;
var hiddenIFrameID = 'hiddenDownloader' + count++;
var iframe = window.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
window.body.appendChild(iframe);
iframe.src = "https://www.shipper-ml.com/viewReports.do?ctrl=reportListForDownload&action=DownloadReport¶m="+d;
}
});
});
}); ")));