Skip to main content

Datetime and range slider tools for Selenium.

Project description

Selenium-Tools provides the following tools for use with Selenium:

  1. Send/receive datetime.datetime objects from web forms.
  2. Drag range sliders to specified values.

Installation

$ pip install selenium-tools

Quickstart

First, clone an example file from the Selenium-Tools repo.

$ curl https://raw.githubusercontent.com/dsbowen/selenium-tools/master/form.html --output form.html

Let's send the current date and time to all input in the form.

from selenium_tools import get_datetime, send_datetime

from selenium.webdriver import Chrome

from datetime import datetime

driver = Chrome()
driver.get('data:text/html,'+open('form.html').read())

datetime_ = datetime.utcnow()

css_selectors = (
    'input[type=date]',
    'input[type=datetime-local]',
    'input[type=month]',
    'input[type=time]',
    'input[type=week]'
)
for selector in css_selectors:
    input_ = driver.find_element_by_css_selector(selector)
    send_datetime(input_, datetime_)
    print(get_datetime(
        input_.get_attribute('type'), 
        input_.get_property('value')
    ))

You'll see the form filled in in your selenium browser and receive the following output in your terminal:

2020-06-30 00:00:00
2020-06-30 15:47:00
2020-06-01 00:00:00
1900-01-01 15:47:00
2020-01-01 00:00:00

We can also drag the range slider as follows:

from selenium_tools import drag_range

range_ = driver.find_element_by_css_selector('input[type=range]')
drag_range(driver, range_, 80)
range_.get_property('value')

Out:

'80'

Citation

@software{bowen2020selenium-tools,
  author = {Dillon Bowen},
  title = {Selenium-Tools},
  url = {https://dsbowen.github.io/selenium-tools/},
  date = {2020-06-29},
}

License

Users must cite this package in any publications which use it.

It is licensed with the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

selenium-tools-0.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

selenium_tools-0.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file selenium-tools-0.0.1.tar.gz.

File metadata

  • Download URL: selenium-tools-0.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for selenium-tools-0.0.1.tar.gz
Algorithm Hash digest
SHA256 aad5f1d35225845a1e7177463090b007d6a9286c7febc806d0065bd9e7738903
MD5 dc53f53902e15ff1cf24572be8f8ca13
BLAKE2b-256 7b0b49fe7c706a0fe4c715b2efeb2d0691d0b00ab8ad489bdeed6490cee214cf

See more details on using hashes here.

File details

Details for the file selenium_tools-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: selenium_tools-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for selenium_tools-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8795e4f3804af836562ff9f3e58de6443752e4d13db38501f8e1026b833ea7a
MD5 36832594a49ce5397c884b2a568c4b7e
BLAKE2b-256 23d3312d801fbca91b8752bd7705a71bc38b33a445eb83e77f3e713c53118551

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page