Selenium Tools
About package
There is a known drag & drop bug that reproduces in frameworks that use webdriver to send commands to browser. This bug is a webdriver's issue and it's unknown when it's going to be fixed (or if it's going to be fixed at all). Current solution uses JavaScript code to simulate drag & drop action on web page. It works in most of the cases when it doesn't work in Selenium.
You may find bug description and current workaround here.
Thanks to druska for his native js drag and drop helper.
Current package is called Selenium Tools for a reason - it will contain more features in future. Feel free to contribute.
Installation
pip install seletools
Drag & Drop
from seletools.actions import drag_and_drop
driver = webdriver.Chrome()
source = driver.find_element(By.CSS_SELECTOR, "...")
target = driver.find_element(By.CSS_SELECTOR, "...")
drag_and_drop(driver, source, target)
Scroll
This one helps to scroll vertically to any element on page, even if it's covered by some other element (like navbar or footer). If there's such obstacle - simply add that covering element into scrolling function as element2.
from seletools.actions import scroll_to_top, scroll_to_bottom
driver = webdriver.Chrome()
element1 = driver.find_element(By.CSS_SELECTOR, "...")
element2 = driver.find_element(By.CSS_SELECTOR, "...") #optional, used only if you have obastacle (like navbar on footer) on top of the element that you need to scroll to
scroll_to_top(driver, element1, element2)
# OR
scroll_to_top(driver, element1)
scroll_to_bottom(driver, element1, element2)
# OR
scroll_to_bottom(driver, element1)
Notes
Drag & Drop action worked with CSS selectors only a while ago. Now it also supports XPath selectors.
Release files for seletools 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| seletools-1.1.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| seletools-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.4 kB
Release files / seletools-1.1.0.tar.gz
| Download URL | seletools-1.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0b67d446cfddd70468e6651856fec17a8cf508ba96d650a3924e7ddb85a797f
|
|
BLAKE2b-256 checksum How to use checksums |
4ab5c85890fded1186a41780c6bb6fefc1bb66367ff17318478ec80f6f2cc017
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.0
|
Release files / seletools-1.1.0-py3-none-any.whl
| Download URL | seletools-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d63adc483baeafc06c3d416a66ad65dc57ce4e0410186411c83e0f5e0570639
|
|
BLAKE2b-256 checksum How to use checksums |
3afa9507947f3ddec2ad383bd8df48ceb1727ed27a24721f81a52fc8f15ef6ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.0
|