browser.get#
Functions#
dimensions(xpath, timeout=None) #
Get width and height of element on the current page in pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the element. | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
tuple[int, int] | Width and height in pixels. |
Example
width, height = browser.get.dimensions("//xpath/to/element")
element(xpath, timeout=None) #
Get single WebElement on the current page by XPath.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the element. | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
WebElement | Web element. |
Example
1 2 | |
elements(xpath, timeout=None) #
Get multiple WebElements on the current page by XPath. Assumes that the XPath targets multiple elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the elements. | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
list[WebElement] | List of web elements of type |
Example
1 2 3 | |
elements_by_tag(tag, timeout=None) #
"Get multiple WebElements on the current page by HTML tag. Assumes that the XPath targets multiple elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag | str | HTML tag of the elements. For example, | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
list[WebElement] | List of web elements of type |
Example
Get and print all paragraphs of a web page:
1 2 3 | |
meta_description() #
Get meta description of the current page.
Returns:
| Type | Description |
|---|---|
str | The meta description content of the current page. If no meta description is found, an empty string is returned. |
Example
1 2 | |
meta_robots() #
Get meta robots configuration of the current page.
Returns:
| Type | Description |
|---|---|
str | The content of meta robots of the current page. For example, if a page has |
Example
1 2 | |
page_title() #
Get page title of the current page.
Returns:
| Type | Description |
|---|---|
str | Page title of the current page. |
Example
1 2 | |
text(xpath, timeout=None) #
Get text from element on the current page.
Note
This method assumes that the text field shouldn't be empty and therefore will retry to get the text (for better support of single-page apps with extended loading time).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the element. | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
str | Text from element. |
Example
1 2 | |
texts(xpath, timeout=None) #
Get array of texts from elements on the current page. Assumes that the XPath targets multiple elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the elements. | required |
timeout | float | None | In seconds. Timeout to wait for elements. If | None |
Returns:
| Type | Description |
|---|---|
list[str] | List of texts from elements. |
Example
1 2 3 | |