Skip to content

browser.iframe#

Functions#

switch_to(xpath, timeout=None) #

Switch to iframe.

Parameters:

Name Type Description Default
xpath str

XPath of the iframe.

required
timeout float | None

In seconds. Timeout to wait for element. If None, the global timeout setting is used (default 5 seconds).

None
Example
browser.iframe.switch_to("//xpath/to/iframe")

switch_to_original_page() #

After switch to iframe, use this to come back to the original page.

Example
1
2
3
4
5
6
7
8
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.iframe.switch_to("//xpath/to/iframe")
    element_text = browser.get.text("//xpath/to/element")
    print(element_text)
    browser.iframe.switch_to_original_page()