Interaction

Interacting with a Browser instance

When a response is rendered, the cookies are inherited:

>>> resp = hrequests.get('https://somewebsite.com')
>>> page = resp.render()
>>> page.cookies: RequestsCookieJar  # cookies are inherited from the session
<RequestsCookieJar[Cookie(version=0, name='1P_JAR', value='2023-07-05-20', port=None, port_specified=False, domain='.somewebsite.com', domain_specified=True...

Pulling page data

Get current page url:

>>> page.url: str
https://www.somewebsite.com/

Get page content:

>>> page.text: str
'<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world\'s information, including webpag'
>>> page.content: bytes
b'<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world\'s information, including webpag'

Get the status of the last navigation:

>>> page.status_code: int
200
>>> page.reason: str
'OK'

Parsing HTML from the page content:

Take a screenshot of the page:

Parameters

Navigate to a url:

Navigate through page history:

Controlling elements

Click an element:

Parameters

Hover over an element:

Parameters

Type text into an element:

Parameters

Drag and drop an element:

Parameters

Check page elements

Check if a selector is visible and enabled:

Parameters

Evaluate and return a script:

Parameters

Awaiting events

Parameters

Wait for a script or function to return a truthy value:

Parameters

Wait for the URL to match:

Parameters

Wait for an element to exist on the page:

Parameters

Wait for an element to be enabled:

Parameters

Screenshot an element:

Parameters

Last updated