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到網頁