Giter VIP home page Giter VIP logo

sh-webdriver's Introduction

Selenium/WebDriver bindings for shell script

NOTE: This project is released as part of the ShellSpec project, but for now it is not related and can be used independently.


Project Status: Preview Release v0.1.0

This project is in the early stages of development. There are unimplemented features and it has not been fully tested. Incompatible changes may be made. Bug reports and pull requests are welcome!

Documentation for library is not yet available, see webdriver.sh.

WebDriver API Support Status


Quick start

#!/bin/sh
set -eu

. ./lib/webdriver.sh

chrome_options() {
  echo '{ "args": [] }'
  # echo '{ "args": ["--headless"] }'
}

# You need to run the `chromedriver` beforehand
WebDriver driver="$(ChromeDriver chrome_options "http://localhost:9515")"
driver get "https://www.google.com"

WebElement element="$(driver find_element "css selector:[name=q]")"
element send_keys "WebDriver" :enter

# **Shorthand**
# driver find_element "css selector:[name=q]" send_keys "WebDriver" :enter

for element_id in $(driver find_elements "css selector:a"); do
  WebElement element="$element_id"
  element attribute "text"
done

driver quit
unset -f element driver

Requirements

  • POSIX shell (dash, bash, ksh, zsh, etc.)
  • curl, jq, base64
  • WebDriver
WebDriver Version
Google Chrome Driver Tested on 89.0.4389.23
Mozilla GeckoDriver Not yet tested
Microsoft Edge Driver Not yet tested
Opera Not yet tested
IEDriver Not yet tested
SafariDriver (Builtin) Not yet tested

Environment variables

  • WEBDRIVER_SH_DEBUG - If set, outputs HTTP logs.

TODO

  • WebDriver API
    • Actions
    • Print
    • HTTP Proxy
    • Shadow root
    • Bidi API, DevTools (Support for WebSocket is required. Feasible?)
  • Additional Functions
    • Select
    • Conditional Waits
    • Events
    • Some useful functions
    • High level API (?)
  • Documentation
    • References
    • Page object models for shell script

License

MIT License

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.