This is the code I am trying to execute: from playwright.sync_api import Playwright, sync_playwright, expect def run(playwright: Playwright) -> None: browser = playwright.chromium.launch(headless=True) context = browser.new_context(ignore_https_errors=True) page = context.new_page() page.goto("https://news.yahoo.com", wait_until="load") page.wait_for_url("https://news.yahoo.com/") page.close() context.close() browser.close() with sync_playwright() as playwright: run(playwright)
I am getting the following error(screenshot attached).
Some insights, the script works fine on a Windows machine locally, but when I try to execute on the Linux Server I get the following error. I have tried to print screenshots and perform a trace for the script. However, the script doesn't go beyond the page.goto("https://news.yahoo.com", wait_until="load").
This thread is trying to answer question "Why is the script timing out inconsistently when trying to navigate to a specific URL using Playwright on a Linux server?"
I have had similar, inconsistent errors when running code from docker containers deployed in our CI/CD system and they are really frustrating. One approach I've used is to use the flaky plugin (https://github.com/box/flaky) but that really just masks the issue rather than properly resolving it.
Does the problem occur if you don't hit yahoo? If you read the end users license agreements, last i checked microsoft, google, and the rest usually call out something to the effect "It is forbidden to use automation or other such tools..." The fact it works once in a while might be more a side effect of restrictions if the detect you are doing are violating said policies, they might slow you down to 1 request per day or whatever their policies are.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].