Code Monkey home page Code Monkey logo

selenium's Introduction

selenium - Selenium Client For Go

GoDoc Travis Go Report Card

About

This is a Selenium client for Go. It supports the WebDriver protocol and has been tested on Selenium WebDriver and ChromeDriver.

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

Installing

Run

go get github.com/tebeka/selenium

Docs

Docs are at https://godoc.org/github.com/tebeka/selenium

AppEngine

GetHTTPClient exposes the HTTP client used by the driver. You can access it to add the request context.

func myRequestHandler(w http.ResponseWriter, r *http.Request) {
    selenium.GetHTTPClient().Transport = &urlfetch.Transport{
        Context:  appengine.NewContext(r),
        Deadline: 30 * time.Second,
    }
    ...
}

Thanks to bthomson for this one.

TODO

  • Finish full WebDriver API.
  • Add usage examples
  • Test Chrome interaction on Travis. Currently, only Firefox is tested.
  • Any additional TODOs marked in the code.
  • Allow testing on Windows and OS X.

Known issues

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.

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

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. ChromeDriver has not yet implemented the nascent W3C standard. So far, this only means that GetCookie is not available for Chrome.

HTMLUnit

  1. Enabling Javscript support in HTMLUnit using Selenium WebDriver 3.4 seems broken, with the root cause not yet diagnosed.

Hacking

Patches are encouraged through GitHub pull requests. Please ensure that a test is added for anything more than a trivial change and that the existing tests pass.

Download Dependencies

First, download the ChromeDriver binary, the Firefox binary and the Selenium WebDriver JARs:

$ cd vendor
$ go run init.go
$ cd ..

You only have to do this once initially and later when version numbers in init.go change.

Ensure that the chromium binary is in your path. If the binary is named differently, run the tests with the flags --chrome_binary=<binary name>.

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. An old version of Firefox and Selenium 2.
    4. HTMLUnit, a Java-based lightweight headless browser implementation.
    5. A new version of Firefox directly against Geckodriver, if the --run_direct_deckodriver_tests flag is provided. (This has known-failing tests and is considered experimental).

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

  • To run only one of the top-level tests, pass -test.run=TestFirefoxSelenium2, -test.run=TestFirefoxSelenium3, -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 Selenium and the browsers.

Testing With 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

License

This project is licensed under the MIT license.

selenium's People

Contributors

tebeka avatar minusnine avatar hnakamur avatar crantok avatar ravitezu avatar hkeide avatar llonchj avatar drmarcii avatar rtm7777 avatar tinyshrimp avatar

Watchers

James Cloos avatar  avatar  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.