Skip to content
Selenium/Webdriver client for Go
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
chrome Added goog:chromeOptions key in addition to chomeOptions to support p… Apr 9, 2018
firefox Fix golint warnings Feb 23, 2017
internal/zip SeleniumHQ/selenium#3055 is fixed in Selenium 3.3.1 Mar 12, 2017
log Provide a more idiomatic log message type Jul 18, 2017
misc/git Add a pre-commit hook that runs gofmt Aug 22, 2017
sauce Avoid PID file collisions that prevent restarting the Sauce proxy Oct 11, 2018
testing Speed up Travis testing: move dependency downloading Aug 23, 2017
vendor Update the version of Sauce Connect Proxy Oct 11, 2018
.gitignore Add API for explicitly waiting for a condition to become true (#91) Aug 21, 2017
.travis.yml
AUTHORS Slightly modify copyright assignment implementation Dec 16, 2016
ChangeLog 0.9.3 Nov 22, 2016
LICENSE Move MIT license file to its recommended name Dec 16, 2016
README.md Extend the timeout for invoking Sauce tests, clean up docs Oct 11, 2018
common.go In debug mode, hide password from selenium url (#59) May 4, 2017
doc.go Rewrite doc.go to remove stale information Aug 22, 2017
example_test.go Expand the example to be runnable, with modification Aug 22, 2017
remote.go
remote_test.go Find the (likely) most recent, highest-versioned JAR/binary Oct 7, 2018
sauce_test.go Send SIGTERM to the Sauce Connect Proxy process when the test exits Oct 11, 2018
selenium.go Support element screenshot (#128) Oct 6, 2018
service.go Use the Xvfb binary in the unit tests (#121) Oct 11, 2018
service_test.go Use the Xvfb binary in the unit tests (#121) Oct 11, 2018

README.md

The most complete, best-tested WebDriver client for Go

GoDoc Travis Go Report Card

About

This is a WebDriver client for Go. It supports the WebDriver protocol and has been tested with various versions of Selenium WebDriver, Firefox and Geckodriver, and Chrome and ChromeDriver,

selenium is currently maintained by Eric Garrido (@minusnine).

Installing

Run

go get -t -d github.com/tebeka/selenium

to fetch the package.

The package requires a working WebDriver installation, which can include recent versions of a web browser being driven by Selenium WebDriver.

Downloading Dependencies

We provide a means to download the ChromeDriver binary, the Firefox binary, the Selenium WebDriver JARs, and the Sauce Connect proxy binary. This is primarily intended for testing.

$ cd vendor
$ go get -d ./...
$ go run init.go --alsologtostderr
$ cd ..

Re-run this periodically to get up-to-date versions of these binaries.

Documentation

The API documentation is at https://godoc.org/github.com/tebeka/selenium. See the example and the unit tests for better usage information.

Known Issues

Any issues are usually because the underlying browser automation framework has a bug or inconsistency. Where possible, we try to cover up these underlying problems in the client, but sometimes workarounds require higher-level intervention.

Please feel free to file an issue if this client doesn't work as expected.

Below are known issues that affect the usage of this API. There are likely others filed on the respective issue trackers.

Selenium 2

  1. Selenium 2 does not support versions of Firefox newer than 47.0.2.

Selenium 3 and Geckodriver

  1. Geckodriver GetAllCookies does not return the expiration date of the cookie.
  2. Selenium 3 NewSession does not implement the W3C-specified parameters.
  3. The Proxy object is misinterpreted by Geckodriver when passed through by Selenium 3.
  4. Maximizing the browser window hangs.
  5. Geckodriver does not support the Log API because it hasn't been defined in the spec yet.
  6. Firefox via Geckodriver (and also through Selenium) doesn't handle clicking on an element.
  7. Firefox via Geckodriver doesn't handle sending control characters without appending a terminating null key.

The Geckodriver team recommends using the newest available Firefox version, as the integration is actively being developed and is constantly improving.

Geckodriver (Standalone)

The Geckodriver team are actively iterating on support for the W3C standard and routinely break the existing API. Support for the newest Geckodriver version within this API will likely lag for a time after its release; we expect the lag to only be several days to a small number of weeks.

Using Geckodriver without Selenium usually has the above known issues as well.

ChromeDriver

  1. Various window-related commands are failing with v62+.
  2. GetCookies can return an incorrect expiration date in v62+.
  3. DeleteCookie doesn't work in v62+.

Breaking Changes

There are a number of upcoming changes that break backward compatibility in an effort to improve and adapt the existing API. They are listed here:

22 August 2017

The Version constant was removed as it is unused.

18 April 2017

The Log method was changed to accept a typed constant for the type of log to retrieve, instead of a raw string. The return value was also changed to provide a more idiomatic type.

Hacking

Patches are encouraged through GitHub pull requests. Please ensure that:

  1. A test is added for anything more than a trivial change and that the existing tests pass. See below for instructions on setting up your test environment.

  2. Please ensure that gofmt has been run on the changed files before committing. Install a pre-commit hook with the following command:

    $ ln -s ../../misc/git/pre-commit .git/hooks/pre-commit

See the issue tracker for features that need implementing.

Testing Locally

Run the tests:

$ go test
  • There is one top-level test for each of:

    1. Chromium and ChromeDriver.
    2. A new version of Firefox and Selenium 3.
    3. HTMLUnit, a Java-based lightweight headless browser implementation.
    4. A new version of Firefox directly against Geckodriver.

    There are subtests that are shared between both top-level tests.

  • To run only one of the top-level tests, pass one of:

    • -test.run=TestFirefoxSelenium3,
    • -test.run=TestFirefoxGeckoDriver,
    • -test.run=TestHTMLUnit, or
    • -test.run=TestChrome.

    To run a specific subtest, pass -test.run=Test<Browser>/<subtest> as appropriate. This flag supports regular expressions.

  • If the Chrome or Firefox binaries, the Selenium JAR, the Geckodriver binary, or the ChromeDriver binary cannot be found, the corresponding tests will be skipped.

  • The binaries and JAR under test can be configured by passing flags to go test. See the available flags with go test --arg --help.

  • Add the argument -test.v to see detailed output from the test automation framework.

Testing With Docker

To ensure hermeticity, we also have tests that run under Docker. You will need an installed and running Docker system.

To run the tests under Docker, run:

$ go test --docker

This will create a new Docker container and run the tests in it. (Note: flags supplied to this invocation are not curried through to the go test invocation within the Docker container).

For debugging Docker directly, run the following commands:

$ docker build -t go-selenium testing/
$ docker run --volume=${GOPATH?}:/code --workdir=/code/src/github.com/tebeka/selenium -it go-selenium bash

Testing With Sauce Labs

Tests can be run using a browser located in the cloud via Sauce Labs.

To run the tests under Sauce, run:

$ go test --test.run=TestSauce --test.timeout=20m \
  --experimental_enable_sauce \
  --sauce_user_name=[username goes here] \
  --sauce_access_key=[access key goes here]

The Sauce access key can be obtained via the Sauce Labs user settings page.

Test results can be viewed through the Sauce Labs Dashboard.

License

This project is licensed under the MIT license.

You can’t perform that action at this time.