🤬
  • Re #958 - remove change screensize, should be in 1280x720 default, was causing "Unable to retrieve content because the page is navigating and changing the content." on some sites

  • Loading...
  • dgtlmoon committed 2 years ago
    f7ea9941
    1 parent d4715e2b
  • ■ ■ ■ ■ ■
    changedetectionio/content_fetcher.py
    skipped 315 lines
    316 316   import playwright._impl._api_types
    317 317   from playwright._impl._api_types import Error, TimeoutError
    318 318   response = None
     319 + 
    319 320   with sync_playwright() as p:
    320 321   browser_type = getattr(p, self.browser_type)
    321 322   
    skipped 51 lines
    373 374   print("response object was none")
    374 375   raise EmptyReply(url=url, status_code=None)
    375 376   
    376  - # Bug 2(?) Set the viewport size AFTER loading the page
    377  - page.set_viewport_size({"width": 1280, "height": 1024})
     377 + 
     378 + # Removed browser-set-size, seemed to be needed to make screenshots work reliably in older playwright versions
     379 + # Was causing exceptions like 'waiting for page but content is changing' etc
     380 + # https://www.browserstack.com/docs/automate/playwright/change-browser-window-size 1280x720 should be the default
     381 +
    378 382   extra_wait = int(os.getenv("WEBDRIVER_DELAY_BEFORE_CONTENT_READY", 5)) + self.render_extract_delay
    379 383   time.sleep(extra_wait)
    380 384   
    skipped 16 lines
    397 401   pass
    398 402   
    399 403   raise JSActionExceptions(status_code=response.status, screenshot=error_screenshot, message=str(e), url=url)
     404 + 
     405 + page.wait_for_timeout(500)
    400 406   
    401 407   self.content = page.content()
    402 408   self.status_code = response.status
    skipped 214 lines
Please wait...
Page is in error, reload to recover