Skip to content

This library provides Selenium Driver in Clojure - a wrapper of 'java selenium webdriver'.

License

Notifications You must be signed in to change notification settings

kay1759/clj-selenium-driver

Repository files navigation

clj-selenium-driver

This library provides Selenium Driver in Clojure - a wrapper of 'java selenium webdriver'.

Installation

Clojars Project

Usage

Example

(require '[clj-selenium-driver.core :as sd])

(sd/set-driver "http://selenium:4444/wd/hub" "chrome" "clj-selenium-driver")

(try
  (sd/get-url "http://localhost/")
  (let [element (sd/find-element :xpath "//div[@id='main']")
        content (sd/get-inner-html element)]
    (println content))
  (catch Exception e
    (println (str "caught exception: " (.toString e))))
  (finally
    (sd/quit)))

API

  • (set-driver <selenium-server> <brower-name> <driver-name>)

  • (close)

  • (quit)

  • (get-url <url>)

  • (get-current-url)

  • (get-title)

  • (get-page-source)

  • (get-window-handle)

  • (get-window-handles)

  • (navigate)

  • (by <locator> <location descripter>)

    • valid locator -> :id, :name, :class-name, :tag-name, :xpath, :css-selector, :link-text, :partical-link-text
  • (back)

  • (forward)

  • (refresh)

  • (to <url>)

  • (find-element <element>)

  • (find-element <locator> <location descripter>)

  • (find-elements <element>)

  • (find-elements <locator> <location descripter>)

  • (get-attribute <element> <attibute-name>)

  • (get-text <element>)

  • (get-value <element>)

  • (get-inner-html <element>)

    • element is a return value of (by <locator> <location descripter>)
  • (click <element>)

  • (checked? <element>)

  • (send-keys <element> <input text>)

  • (send-return <element>)

  • (select-by-index <element> <index number>)

  • (select-by-visible-text <element> <text>)

Environment

Operational acceptance testing

  • docker image selenium/standalone-chrome-debug:3.141.59
  • docker image selenium/standalone-firefox-debug:3.141.59

Tests

  • modify line 6 of 'test/clj_selenium_driver/core_test.clj' file, as your selenium environment.
lein test

References:

Licence:

[MIT]

Author

Katsuyoshi Yabe

About

This library provides Selenium Driver in Clojure - a wrapper of 'java selenium webdriver'.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published