I have to download 2 files from a website and rename the files based on the report type and move it to the specific folder.
I tried downloading the file using xpath but unable to do so.
//*@id="ctrl1805929160"]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[10]/td[1]
public static void execute(WebDriver wd) throws Throwable{
wd.get("https://www.shipper-ml.com/viewReports.do");
Thread.sleep(2000);
List<WebElement> list= wd.findElements(By.xpath("//table[@class='lcb']/tbody/tr/td/table[@class='ibody']/tbody/tr/td[contains(translate(text(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),06)]/parent::tr/td[10]/a"));
int i = 0;
FileUtils.cleanDirectory(new File("C:\\Users\\NEA558\\Desktop\\New_Folder\\Files"));
for (WebElement element:list)
{
i++;
element.click();
Thread.sleep(1000);
System.out.println((element.findElement(By.xpath("(//table[@class='lcb']/tbody/tr/td/table[@class='ibody']/tbody/tr/td[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),06)]/parent::tr/td[10])["+i+"]")).getText()).substring(0,3));
String report_type = (element.findElement(By.xpath("(//table[@class='lcb']/tbody/tr/td/table[@class='ibody']/tbody/tr/td[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),06)]/parent::tr/td[10])["+i+"]")).getText()).substring(0,3);
}
}
Table source : https://www.shipper-ml.com
I am getting below error message when I am executing the code.
Element info: {Using=xpath, value=//table[@class='lcb']/tbody/tr/td/table[@class='ibody']/tbody/tr/td[contains(translate(text(),'0123456789'),'06')]/parent::tr/td[1]/a}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:437)
at org.openqa.selenium.remote.RemoteWebDriver.findElementsByXPath(RemoteWebDriver.java:513)
at org.openqa.selenium.By$ByXPath.findElements(By.java:356)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:398)
at package1.Test_new.execute(Test_new.java:80)
at package1.Test_new.main(Test_new.java:105)
I believe I am doing some mistake in giving the xpath. Can somebody help me with that.