playwright

Scrapy Playwright Page Method: Prevent timeout error if selector cannot be located

Scrapy Playwright Page Method: Prevent timeout error if selector cannot be located Question: My question is related to Scrapy Playwright and how to prevent the Page of a Spider from crashing, if in the course of applying a PageMethod a specific selector cannot be located. Below is a Scrapy Spider that uses Playwright to interact …

Total answers: 2

Converting request interception example from Cypress to Playwright Python

Converting request interception example from Cypress to Playwright Python Question: The Cypress project has a sample test on how to intercept and modify AJAX calls and I wanted to rewrite the same example in Playwright for Python (pytest). The example consists on intercepting and modifying an Ajax call that feeds the Comments section of a …

Total answers: 1

Pause the main thread during the execute callback function

Pause the main thread during the execute callback function Question: I am trying to use page.on to listening certain event, and once it is triggered I want to use callback function to handle it and pause the main thread operation till the callback finished. How can I achieve that? So far it is what I …

Total answers: 1

Playwright times out in while-loop

Playwright times out in while-loop Question: I am using Playwright with Python to scrape data from an apartment leasing website. The following code handles a pop-up in a while-loop that appears only when an availability date for that unit is some time in the future and asks to "Change Desired Move-in Date." This pop-up only …

Total answers: 1

Playwright => Not all the page loading

Playwright => Not all the page loading Question: I’m writing a Python script using playwright. I would like to wait the complete loading of a page (for example https://meteofrance.com/) before taking the associated snapshot: import asyncio from playwright.async_api import async_playwright from playwright.sync_api import Playwright, sync_playwright async def take_screenshot(url,filename): async with async_playwright() as p: browser = …

Total answers: 1

Expect value of a dropdown select based on option text

Expect value of a dropdown select based on option text Question: We have a dropdown select <select id="favorite-colors" multiple> <option value="R">Red</option> <option value="G">Green</option> <option value="B">Blue</option> </select> In playwright we can use to check the value expect(locator).to_have_values([re.compile(r"R"), re.compile(r"G")]) See: https://playwright.dev/python/docs/api/class-locatorassertions#locator-assertions-to-have-values But how can I use the expect to check if the selection is "Red" or "Green" …

Total answers: 2

Python playwright unable to access elements

Python playwright unable to access elements Question: I want to scrape the words which reside in the <li> elements. The results return an empty list. Are they resided within a frame because as I can see they are not within any <iframe><iframe> elements? If they do how do you access the frame or find the …

Total answers: 2

How to get all data when "show more" button clicked with scrapy-playwright

How to get all data when "show more" button clicked with scrapy-playwright Question: Currently, I’ve had trouble getting all data on this page: https://www.espn.com/nba/stats/player/_/season/2023/seasontype/2 so if scrape right now it only gets 50 of the data, this is not what I want, what I want is to scrape all data, to show all table data …

Total answers: 1

Iterate through a html file and extract data to CSV file

Iterate through a html file and extract data to CSV file Question: I have searched high and low for a solution, but non have quite fit what I need to do. I have an html page that is saved, as a file, lets call it sample.html and I need to extract recurring json data from …

Total answers: 2

Why playwright miss pattern url?

Why playwright miss pattern url? Question: I need to handle request with certain url and im trying to do it like this: await page.route("**/api/common/v1/play?**", handle_data_route) But it also handles a url like this: api/common/v1/play_random? Asked By: kshnkvn || Source Answers: Try using a regular expression instead await page.route(/^.*/api/common/v1/play?.*$/, handle_data_route) Answered By: noah1400

Total answers: 1