Open yanxiang-wang opened 1 year ago
Playwright and Selenium are working with different concepts. A Locator is always Truthy, only when you actually call locator.is_visible()
it will check on the page if a certain element is visible.
So you should modify it to e.g.
if checkbox.is_visible():
logger.debug("Cloudflare verify checkbox found")
Playwright and Selenium are working with different concepts. A Locator is always Truthy, only when you actually call
locator.is_visible()
it will check on the page if a certain element is visible.So you should modify it to e.g.
if checkbox.is_visible(): logger.debug("Cloudflare verify checkbox found")
Thanks for the quick reply. Even the Locator checkbox
is always True
, the logger still show not detected
. I tried with is_visible()
. The output is the same. I guess the Playwright still didn't capture the iframe
as selenium. What do you think?
This is related to https://github.com/microsoft/playwright/issues/21780.
This is Firefox-specific, the same snippet works for me in Chromium. The issue is that cloudflare iframe is forced oopif or get some special security handling, has an empty url, and Playwright fails to evaluate inside.
Here is an example error when trying to access iframeElement.contentFrame()
:
elementHandle.contentFrame: Protocol error (Page.describeNode): error in channel "content::9/12/2": exception while running method "describeNode" in namespace "page": Permission denied to access property "docShell" on cross-origin object
_describeNode@chrome://juggler/content/content/PageAgent.js:417:47
Here is trying to evaluate inside page.frames()[1]
:
frame.evaluate: Execution context was destroyed, most likely because of a navigation.
System info
Source code
Link to the GitHub repository with the repro
[https://github.com/your_profile/playwright_issue_title]
or
Test file (self-contained)
Steps
Expected
I use the similar xpath selectors with Selenium, and it can detect the iframe.
Actual
Selenium:
Playwright: