• Stars
    star
    2,503
  • Rank 18,335 (Top 0.4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 12 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Selenium/Webdriver client for Go

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 run init.go --alsologtostderr  --download_browsers --download_latest
$ 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 unit tests(for sauce, selenium and service) 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

No longer supported.

Selenium 3

  1. Selenium 3 NewSession does not implement the W3C-specified parameters.

Geckodriver (Standalone)

  1. Geckodriver does not support the Log API because it hasn't been defined in the spec yet.
  2. Firefox via Geckodriver (and also through Selenium) doesn't handle clicking on an element.
  3. Firefox via Geckodriver doesn't handle sending control characters without appending a terminating null key.

Chromedriver

  1. Headless Chrome does not support running extensions.

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

Install xvfb and Java if they is not already installed, e.g.:

sudo apt-get install xvfb openjdk-11-jre

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=$(pwd):/code --workdir=/code -it go-selenium bash
root@6c7951e41db6:/code# testing/docker-test.sh
... lots of testing output ...

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.

More Repositories

1

go2xunit

Convert "go test" output to xunit compatible (used in Jenkins/Hudson)
Go
162
star
2

talks

Jupyter Notebook
49
star
3

snowball

Snowball stemmer for Go
C
44
star
4

atexit

atexit for Go
Go
28
star
5

expmod

Prints GitHub project description for every direct dependency on GitHub in go.mod
Go
27
star
6

toggl

Simple toggl command line client
Go
26
star
7

hiver

Hive Thrift Client for Python
Python
23
star
8

pycue

Python
23
star
9

go-brain-teasers

Code from "Go Brain Teasers" book
Go
20
star
10

pythonwise

Code from https://pythonwise.blogspot.com
Python
20
star
11

bunder

Check that Go benchmark is under given threshold.
Go
17
star
12

forging-python

Code for the book http://forging-python.com
Makefile
16
star
13

py2go-cheatsheet

Python
16
star
14

nrsc

Resource compiler for Go
Go
11
star
15

seamless

seamless (no downtime) upgrades
Go
10
star
16

flags

Useful command line flag types for Go (File, URL, Time ...)
Go
10
star
17

strftime

strftime for Go
Go
9
star
18

popen

popen for Clojure
Clojure
9
star
19

ingress

Python REPL over the network
Python
8
star
20

feedme

RSS reader for Clojure
Clojure
8
star
21

deque

Python's collections.deque implementation in Go
Go
5
star
22

viaenv

Configuration via Environment for Python
Python
5
star
23

python-brain-teasers

Python
4
star
24

recheck

Static checker for regular expressions in Go
Go
4
star
25

zipstream

Zip Reader for Hadoop Streaming
Java
3
star
26

adventofcode

Solving http://adventofcode.com/
Go
2
star
27

df

Go
2
star
28

gadwall

Command line client to duckdb
Python
2
star
29

jtime

Flexible time marshal/unmarshal for JSON
Go
2
star
30

base62

base62 encoding for go
Go
2
star
31

clj-strftime

strftime for Clojure
Clojure
2
star
32

dr-evil

Evail web debugger for Clojure
Clojure
2
star
33

iocp

Python
2
star
34

timeat

Show current time at location
Go
2
star
35

limit_reader

Limit the number of bytes that can be read from an object. Makes your code more secure.
Python
2
star
36

lein-uberjar-demo

2
star
37

must

Go
2
star
38

whoops

WebHDFS client for Python
Python
2
star
39

benchlog

Logs for running benchmarks in Go
Go
2
star
40

desktop

A Go package to open uri with default handlers
Go
2
star
41

vulnz

Use golang.org/x/vuln to scan your dependencies
Go
2
star
42

back-at

Go
2
star
43

annotated-go-hw

HTML
1
star
44

learn-rust

Rust
1
star
45

itm

C++
1
star
46

math-quiz

HTML
1
star
47

go-lisp-book

Go
1
star
48

simgo

Process-based discrete-event simulation framework
Go
1
star
49

logbot

Jabber (XMPP) logging bot
Python
1
star
50

pytest-defer

Python
1
star
51

cml-painless

Python
1
star
52

dm-talks

Talks at DemandMedia
Go
1
star
53

crime

Go
1
star
54

timeseq

In memory time sequence for Go
Go
1
star
55

clearml-titanic

Python
1
star
56

titanic

Example repo
Python
1
star
57

fzu

Python
1
star
58

rs2019-words

Python
1
star
59

go-israel

1
star
60

cryptkeeper

Python
1
star
61

leetcode

Solving LeetCode problems
Go
1
star