Questions tagged [playwright-python]

Microsoft Playwright is a web automation library comparable to Selenium. This tag refers to the Python port of the library.

Microsoft Playwright is a web automation library comparable to Selenium. Originally a Javascript project, this is now also available in Python.

Related tags:

365 questions
10
votes
1 answer

How to set Playwright not automatically follow the redirect?

I want to open a website using Playwright, but I don't want to be automatically redirected. In some other web clients, they have parameter link follow=False to disable automatically following the redirection. But I can't find it on Playwright. async…
oon arfiandwi
  • 515
  • 1
  • 8
  • 21
10
votes
2 answers

Is there a way to connect to my existing browser session using playwright

I wish to connect to a website and download some pdf files. The website allows us to view the content only after log in. It asks us to log in using OTP and can't be login at more than 3 devices simultaneously. I wish to download all the pdf listed.…
9
votes
4 answers

How to download PDF files with Playwright? (Python)

I'm trying to automate the download of a PDF file using Playwright, I've the code working with Selenium, but some features in Playwright got my attention. The real problem the documentation isn't helpful. When I click on download I get this: And I…
K3yg
  • 93
  • 1
  • 5
8
votes
5 answers

Using Playwright for Python, how do I select an option from a drop down list?

This is a followup to this question on the basic functionality of Playwright for Python. How do I select an option from a drop down list? This example remote controls a vuejs-webseite that has a drop down list of fruits like "Apple", "Banana",…
576i
  • 7,579
  • 12
  • 55
  • 92
8
votes
5 answers

Using Playwright for Python, how do I select (or find) an element?

I'm trying to learn the Python version of Playwright. See here I would like to learn how to locate an element, so that I can do things with it. Like printing the inner HTML, clicking on it and such. The example below loads a page and prints the…
576i
  • 7,579
  • 12
  • 55
  • 92
7
votes
2 answers

How can I handle the wait_for_selector function's TimeoutError in Playwright-python?

I want to use Except TimeoutError to handle the timeout problem. But the script always throws me a TimeoutError, not print a message as I planed. Here is my code: try: await page.wait_for_selector("#winiframe_main", timeout=10000,…
Kaol
  • 431
  • 2
  • 7
  • 16
7
votes
2 answers

In Playwright for Python, how do I get elements relative to ElementHandle (children, parent, grandparent, siblings)?

In playwright-python I know I can get an elementHandle using querySelector(). Example (sync): from playwright import sync_playwright with sync_playwright() as p: for browser_type in [p.chromium, p.firefox, p.webkit]: browser =…
buddemat
  • 4,552
  • 14
  • 29
  • 49
6
votes
1 answer

print page source in python playwright

I have PHP script, and Im calling python function with this code with URL parameter: import json import sys import urllib.parse link = urllib.parse.unquote(sys.argv[1]) from playwright.sync_api import sync_playwright with sync_playwright() as p: …
user15647143
6
votes
1 answer

What are the differences between Python Playwright sync vs. async APIs?

I've started learning playwright-python and the package playwright has the two submodules async_api and sync_api. However I could not find any deeper description or discussion on their respective benefits and drawbacks. From their names I assume…
buddemat
  • 4,552
  • 14
  • 29
  • 49
6
votes
2 answers

How do you open multiple pages asynchronously with Playwright Python?

I want to open multiple urls at once using Playwright for Python. But I am struggling to figure out how. This is from the async documentation: async def main(): async with async_playwright() as p: for browser_type in [p.chromium,…
5
votes
0 answers

Bright Data scraping browser: "Forbidden action: password typing is not allowed"

Using the Bright Data scraping browser via the Playwright Python library I wrote the following code snippet: await page.goto('https://example.com/login/') await page.fill('input[name="username"]', username) await page.fill('input[name="password"]',…
Bence P
  • 51
  • 2
5
votes
3 answers

Python Playwright start maximized window

I have a problem starting Playwright in Python maximized. I found some articles for other languages but doesn't work in Python, also nothing is written about maximizing window in Python in the official documentation. I tried browser =…
bbfl
  • 277
  • 1
  • 2
  • 16
5
votes
1 answer

How to catch the redirect with a webapp using playwright

When you go to this link, the page will run some javascript and then automatically redirect to a pdf. I have a hard time getting that final url from Playwright. from playwright.sync_api import sync_playwright with sync_playwright() as p: …
chhenning
  • 2,017
  • 3
  • 26
  • 44
5
votes
4 answers

How to use the Playwright library in a Jupyter notebook instead of using a regular .py script (on Windows)

I want to use an automated browser and execute my steps with jupyter notebook cells instead of using .py scripts. This works fine with the browser automation library called selenium. It does not work fine with the library called Playwright. In fact…
5
votes
2 answers

Start playwright driver session but not incognito

Currently i open a new browser session using the code below, but it always starts as incognito, can I start a new chromium session but not as incognito?: from behave import * from playwright.sync_api import sync_playwright import time class…
Gabi
  • 51
  • 1
  • 4
1
2 3
24 25