Skip to main content

selenium-cmd

selenium-cmd is a small tool with which you can perform basic actions using a selenium webdriver object.

table of contents

  1. installation
  2. usage
  3. commands
    1. get
    2. exit
    3. click
    4. extract
    5. select
    6. write

installation

You can simply use

pip install selenium-cmd

usage

You can use the SeleniumCmd class wherever you want in your script.
You can do so by importing SeleniumCmd from selenium_cmd.

from selenium_cmd import SeleniumCmd

SeleniumCmd(your_driver).cmdloop()

If you do not provide your own driver, SeleniumCmd will instantiate one using Chrome() from selenium.webdriver.
This will open a prompt where you can type your commands looking like this:

selenium-cmd version 0.0.2
>

commands

get

With get you can navigate to different websites.
The following will navigate to http://example.com:

>get http://example.com

exit

The exit command will stop the execution of SeleniumCmd and continue with your regular program execution.

>exit

click

The click command will click the first element found specified by an XPath.
The following example will click the first link on http://example.com:

>get http://example.com
>click //a

extract

The extract command will print all elements matched by the provided XPath expression to your command line.
The following example will print all quotes from https://quotes.toscrape.com/:

>get https://quotes.toscrape.com/
>extract //span[@class="text"]/text()
1 The world as we have created it is a process of our thinking. It cannot be changed without changing our thinking.
2 It is our choices, Harry, that show what we truly are, far more than our abilities.
3 There are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle.
4 The person, be it gentleman or lady, who has not pleasure in a good novel, must be intolerably stupid.
5 Imperfection is beauty, madness is genius and it's better to be absolutely ridiculous than absolutely boring.
6 Try not to become a man of success. Rather become a man of value.
7 It is better to be hated for what you are than to be loved for what you are not.
8 I have not failed. I've just found 10,000 ways that won't work.
9 A woman is like a tea bag; you never know how strong it is until it's in hot water.
10 A day without sunshine is like, you know, night.

select

The syntax for the select command is: select xpath option
The select command will select an option by value from a select tag. The select tag needs to be specified by an XPath expression.
The following example will select the option "css" in the first select tag on https://www.w3docs.com/learn-html/html-select-tag.html:

>get https://www.w3docs.com/learn-html/html-select-tag.html
>select //select[@aria-label="Books"] css

write

The syntax for the write command is: write xpath text
The write command will write text to a text input field as specified. Text that contains whitespace must be enclosed in quotation marks.
The following example will write "Hello World!" in the search box of https://developer.mozilla.org/

>get https://developer.mozilla.org/
>write //input[@id="main-q"] "Hello World!"

Metadata

Release files for selenium-cmd 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for selenium-cmd 0.0.2
File Size Uploaded Provenance Actions
selenium-cmd-0.0.2.tar.gz 4.6 kB Without provenance Details for selenium-cmd-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for selenium-cmd 0.0.2
File Interpreter ABI Platform Actions
selenium_cmd-0.0.2-py3-none-any.whl Python 3 none any Details for selenium_cmd-0.0.2-py3-none-any.whl

Total release size: 10.3 kB

Release files / selenium-cmd-0.0.2.tar.gz

Download URL selenium-cmd-0.0.2.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f9226a5347689d9a908e68b3305a51415914248a0a295f2f23b6b74cb4f1ae0a
BLAKE2b-256 checksum
How to use checksums
90343d7f9b8dcaf80a44686b9a2ca8be8908db3e00b52ea5c7ba098d29c62d0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

Release files / selenium_cmd-0.0.2-py3-none-any.whl

Download URL selenium_cmd-0.0.2-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ffd7fd8de5cf3558a14c7a1f97d0712095de6f8cf4584cd4c092c98cb7e975c
BLAKE2b-256 checksum
How to use checksums
97c1bbb4e4b028d58b40767fba8166cfbf2386c4a747470bdedc5a57497681b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

Security for selenium-cmd 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page