browser.get#
Functions#
dimensions(xpath, timeout=None)
#
Get width and height of element 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
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 WebElement
s 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 WebElement
s 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 |
|
page_title()
#
Get page title of the current page.
Returns:
Type | Description |
---|---|
str | Page title. |
Example
1 2 |
|
text(xpath, timeout=None)
#
Get text from element.
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. 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 |
|