I am trying to validate content of pdf by copying the content to clipboard and transferring to String. Below is my code
ArrayList<String> tabs = new ArrayList<String> (driver.getWindowHandles());
for (String string : tabs) {
System.out.println("tab id:: "+string);
}
driver.switchTo().window(tabs.get(1)); //pdf opens in new tab so switching to new tab
pause(5000);
String selectAll = Keys.chord(Keys.CONTROL,Keys.chord("a"));
String copy = Keys.chord(Keys.CONTROL,Keys.chord("c"));
driver.switchTo().frame(driver.findElement(By.xpath("//html/body//div/div/iframe")));
driver.findElement(By.xpath("//*[@id='plugin']")).sendKeys(selectAll); //Select all works on the opened pdf
pause(3000);
driver.findElement(By.xpath("//*[@id='plugin']")).sendKeys(copy);
pause(5000);
Clipboard clipboard2 = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable contents = clipboard2.getContents(null);
String x = (String) contents.getTransferData(DataFlavor.stringFlavor);
System.out.println(x); //getting worng out put here instead of pdf content
Selecting the content works , but i get some random output like this
tab id:: CDwindow-FC2070E3D2902357E08E5D6720AF9766
tab id:: CDwindow-D06392BD9261B14C083395D57AE805FA
Clipboard clipboard2 = Toolkit.getDefaultToolkit().getSystemClipboard();
Here is the page source for Embedded pdf
Not sure what wrong i am doing. Can any one please help. Thank you.
Chomredriver 2.39 Chrome version 66