0

Page source

How to access the virutal document #document contents using playwright ? I tried using iFrame and Pagelocator. However, I am unable to reach document location.

Is there an option in Playwright to approach this? This is the page URL - https://sites.google.com/view/pinnednote/home

1
  • "I tried using iFrame and Pagelocator"--please share these attempts as minimal reproducible examples. Commented Dec 15, 2022 at 15:36

1 Answer 1

1

Yes, you have frame_locator for python or frameLocator for javascript.

Here an example in your page (Using python)

# Import needed libs
from playwright.sync_api import sync_playwright

# We initiate the playwright page
p = sync_playwright().start()
browser = p.chromium.launch(headless=False)
context = browser.new_context()
page = context.new_page()

# Navigate
page.goto("https://sites.google.com/view/pinnednote/home")

# We get the first iframe
iframe1 = page.frame_locator("//iframe[@jsname='WMhH6e']")

# We get the iframe inside the first iframe
iframe2 = iframe1.frame_locator("#innerFrame")

# We get the iframe inside the second iframe
iframe3 = iframe2.frame_locator("#userHtmlFrame")

# We print the title of this third iframe
print(iframe3.locator("//title").inner_text())

The page has a lot of iframes being honest.

About managing frames with playwright: Playwirght frameLocator

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.