Code Monkey home page Code Monkey logo

shellnium's Introduction


Shellnium

Shellnium is the selenium WebDriver for Bash.
You can exec selenium simply on your terminal. All you need is Bash or Zsh.

#!/usr/bin/env bash
source ./selenium.sh

main() {
    # Open the URL
    navigate_to 'https://google.com'

    # Get the search box
    local searchBox=$(find_element 'name' 'q')

    # send keys
    send_keys $searchBox "panda\n"
}

main

Documentation

https://shellnium-site.vercel.app

If you learn by watching videos, check out this screencast by @gotbletu to explore shellnium features.

shellnium - Automate The Web Using Shell Scripts - Linux SHELL SCRIPT

Quick Start

# Run ChromeDriver before execute script
$ chromedriver

# execute script
$ sh demo.sh

You can add chrome options. e.g. --headless.

$ sh demo.sh --headless --lang=es

Make sure you have the right version of ChromeDriver and GoogleChrome.

# Check the version of Google Chrome
# ex. MacOS
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version
Google Chrome 89.0.4389.82

# Check the version of ChromeDriver
$ chromedriver --version
ChromeDriver 89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294})

Download chromedriver
https://chromedriver.chromium.org/downloads

Requirements

  • jq

Methods

Shellnium provides the following methods. See document or core.sh for details.

Session

  • is_ready
  • new_session
  • delete_session
  • get_cookies
  • set_cookies
  • delete_cookies

Navigate

  • navigate_to
  • get_current_url
  • get_title
  • back
  • forward
  • refresh

Timeouts

  • get_timeouts
  • set_timeouts
  • set_timeout_script
  • set_timeout_pageLoad
  • set_timeout_implicit

Element Retrieval

  • find_element
  • find_elements
  • find_element_from_element
  • find_elements_from_element
  • get_active_element

Element State

  • get_attribute
  • get_property
  • get_css_value
  • get_text
  • get_tag_name
  • get_rect
  • is_element_enabled

Element Interaction

  • send_keys
  • click
  • element_clear

Document

  • get_source
  • exec_script
  • element_screenshot
  • screenshot

Cookies

  • get_all_cookies
  • get_named_cookie
  • add_cookie
  • delete_cookie
  • delete_all_cookies

Context

  • get_window_handle
  • get_window_handles
  • delete_window
  • new_window
  • switch_to_window
  • switch_to_frame
  • switch_to_parent_frame
  • get_window_rect
  • set_window_rect
  • maximize_window
  • minimize_window
  • fullscreen_window

Article

English https://dev.to/rasukarusan/shellnium-simple-selnium-webdriver-for-bash-1a9k

Japanese https://qiita.com/Rasukarusan/items/70a54bd38c71a07ff7bd

Example

$ sh demo2.sh

demo2.sh is required iTerm2 and Mac OS.

This script is headless and display chromedriver's behavior as iTerm's background with AppleScript.

Reference

LICENSE

MIT

shellnium's People

Contributors

rasukarusan avatar jontxux avatar 644 avatar dogfootruler-kr avatar fabriciocybershell avatar

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.