Skip to content

Commit 6a043d8

Browse files
committed
Update an example that prints to a PDF
1 parent e2e0695 commit 6a043d8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import base64
21
from seleniumbase import SB
3-
from selenium.webdriver.common.print_page_options import PrintOptions
42

5-
with SB(uc=True, test=True, ad_block=True) as sb:
3+
with SB(uc=True, test=True, pls="none") as sb:
64
url = "https://seleniumbase.io"
75
sb.activate_cdp_mode(url)
8-
sb.reconnect() # To access WebDriver methods
9-
print_options = PrintOptions()
10-
pdf_base64 = sb.driver.print_page(print_options)
11-
with open("downloaded_files/sb.pdf", "wb") as f:
12-
f.write(base64.b64decode(pdf_base64))
6+
sb.assert_title("SeleniumBase Docs")
7+
file_path = "downloaded_files/sb.pdf"
8+
sb.print_to_pdf(file_path)
9+
sb.assert_downloaded_file("sb.pdf")
10+
sb.assert_pdf_text(file_path, "SeleniumBase")

0 commit comments

Comments
 (0)