0
A
回答
0
您可以直接发送请求的url,而不涉及硒和获得与PDF文件的内容的字节数组。之后,您可以使用一些PDF库(看起来像ITextSharp很受欢迎)阅读文件内容。
0
在Chrome浏览器内部,所有对话框弹出窗口都是html页面,因此您可以使用Selenium单击它们。 您可以导航到一个页面,模拟Ctrl + P键盘按钮按下,切换到打印对话窗口,点击更改按钮更改打印机,点击保存为PDF,点击保存按钮,当显示“另存为”框时 - 模拟输入键盘按钮按下即可实际保存文件。 我没有做C#,但这里是如何看起来像在Java中,实际上我已经测试它,它实际上工作:
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_P);
robot.keyRelease(KeyEvent.VK_P);
robot.keyRelease(KeyEvent.VK_CONTROL);
// get current browser window handles and switch to window with handle that is last in the list
Set<String> windowHandles = driver.getWindowHandles();
for (String handle : windowHandles) {
driver.switchTo().window(handle);
}
driver.findElement(By.xpath("//button[contains(text(), 'Change')]")).click();
driver.findElement(By.xpath("//span[contains(text(), 'Save as PDF')]")).click();
driver.findElement(By.xpath("//button[contains(text(), 'Save')]")).click();
// you might need to add waiter here that waits a second, since script is too fast
// and needs to wait for save dialog box to be shown
robot.keyPress(KeyEvent.VK_ENTER);
相关问题
- 1. Nutch Raw Html Saving
- 2. Kinect Stream Saving
- 3. BotData not saving
- 4. Django ForeignKeys not saving
- 5. NSUserDefaults not saving
- 6. Rails Hstore dateTime saving
- 7. PHP Redis Session not saving
- 8. UserDefaults not saving values iphone
- 9. Javascript,not saving to localstorage
- 10. 阅读pdf页数与C + +
- 11. Print page as pdf selenium python
- 12. store.root.attributes not saving - 熊猫和Pytables
- 13. Glance image create stuck in SAVING status
- 14. PyGame Saving Webcam,图像分割
- 15. ruby on rails id not saving
- 16. selenium c#
- 17. selenium c#
- 18. Selenium C#,WebDriverWait timeout
- 19. hasOne relationship saving new record instead of using existing one
- 20. Selenium C#'OpenQA.Selenium.ElementNotVisibleException'error
- 21. Selenium Chromedriver C#findelementsbytagname(“A”)
- 22. 使用C划分PDF页面#
- 23. 在Objective-C中创建多页PDF
- 24. C#webBrowser导航到另一页pdf
- 25. 怎么去PDF的下一个页面在Objective-C,如果PDF具有多页
- 26. OpenQA.Selenium.NoSuchElementException - C#Selenium
- 27. Selenium 2 C#WebDriverBackedSelenium
- 28. Selenium WebDriver(Ruby):如何下载PDF文件?
- 29. 使用Selenium WebDriver下载pdf for Firefox
- 30. PDF到网页