このページをPDFで直接保存するにはどうすればよいですか?セレンがクロムダイアログボックスを制御できないことは知っています...別の方法がありますか?C#Selenium Saving PDFページ
0
A
答えて
0
あなたは直接関与せずにセレンURLにリクエストを送信し、PDFファイルの内容をバイト配列を取得することができます。その後、いくつかのPDFライブラリを使用してファイルコンテンツを読むことができます(ITextSharpのように見えます)。
0
Chromeブラウザ内では、すべてのダイアログポップアップはhtmlページなので、Seleniumを使用してそれらをクリックできます。 あなたの場合は、ページに移動し、Ctrl + Pキーボードボタンを押す、ダイアログボックスの印刷に切り替える、変更ボタンをクリックしてプリンタを変更する、PDFに保存する、保存ボタンをクリックする、 - simulate実際にファイルを保存するには、キーボードボタンを押します。 私は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. 分割PDFページC#
- 2. Rails Radiant saving directory
- 3. Selenium webdriver pdf
- 4. Laravel Eloquent Batch Saving
- 5. jQuery webcam plugin - saving image
- 6. page as pdf selenium python
- 7. php cURL cookie saving empty
- 8. Delphi - Indy - saving GMail draft
- 9. Swift Stripe Saving Card Integration
- 10. Python + Selenium + PhantomJS PDFへのレンダリング
- 11. Selenium Webdriver C#
- 12. C#Selenium Implicit Wait
- 13. java game saving program wake work
- 14. Selenium C#
- 15. C#Extending Selenium Webdriverクラス
- 16. Selenium Webdriver C#
- 17. SeleniumのPDFポップアップとのやり取り
- 18. PDFを解析してObjective-cのPDFページの画像を取得する
- 19. c#geckodriver selenium ff
- 20. OpenQA.Selenium.NoSuchElementException - C#Selenium
- 21. c#selenium chromedriver flash
- 22. Laravel saving雄弁のモデルのリスト
- 23. pdfファイルのページ数
- 24. ImageMagickには、PDF => PDF複数ページ
- 25. pdfページを使用してpdfページを編集する
- 26. SeleniumとGoodreadsのページ設定
- 27. Seleniumでのページのロードタイムアウト
- 28. itextsharpトリミングpdfドキュメントのページ
- 29. C#Selenium Chromeホームページ変更
- 30. C#Selenium WebDriverスイッチ/ケース