browser.get.url#
Functions#
current() #
Get URL of the current page, e.g. https://example.com.
Returns:
| Type | Description |
|---|---|
str | URL of the current page, e.g. |
Example
This will output the URL https://example.com in the terminal:
1 2 3 4 5 6 | |
current_domain() #
Get domain of the current page, e.g. example.com.
Returns:
| Type | Description |
|---|---|
str | Domain of the current page, e.g. |
Example
This will output the domain example.com in the terminal:
1 2 3 4 5 6 | |
from_image(xpath, timeout=None) #
Get the source URL of an <img> image element.
Note
This method targets the src attribute of an <img> image element. And it assumes that the image isn't empty and therefore will retry to get the URL (for better support of single-page apps with extended loading time).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the image. Should target an | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
str | None | URL source of the image. If the image does not exist, |
Example
1 2 | |
from_images(xpath, timeout=None) #
Get list of source URLs of a group of <img> image elements.
Note
This method targets the src attribute of the <img> image elements. And it assumes that the XPath targets multiple images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the images. Should target | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
list[str | None] | List of image URLs. If an image does not exist, |
Example
1 2 3 | |
from_link(xpath, timeout=None) #
Get the source URL of an <a> link element.
Note
This method targets the href attribute of the <a> link element. And it assumes that the link isn't empty and therefore will retry to get the URL (for better support of single-page apps with extended loading time).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the link. Should target an | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
str | None | URL of the link. If the link does not exist, |
Example
1 2 | |
from_links(xpath, timeout=None) #
Get list of source URLs of a group of <a> link elements.
Note
This method targets the href attribute of the <a> link elements. And it assumes that the XPath targets multiple links.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpath | str | XPath of the links. Should target | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
| Type | Description |
|---|---|
list[str | None] | List of link URLs. If a link does not exist, |
Example
1 2 3 | |