Skip to content
Go WebDriver library
Go
Find file
Latest commit 27102f0 @nl5887 nl5887 removed session returns
Failed to load latest commit information.
.gitignore
LICENSE
README.md
driver.go
driver_test.go
error.go
session.go

README.md

gowebdriver

Golang Webdriver library

Sample

package main

import (
        "io"
        "os"

        webdriver "github.com/dutchcoders/gowebdriver"
)

func main() {
        wd := webdriver.New(
                webdriver.BrowserName("phantomjs"),
                webdriver.PageLoadingStrategyEager,
                webdriver.AcceptSslCerts(true),
                webdriver.Platform("ANY"),
                webdriver.Version(""),
                webdriver.LocationContextEnabled(true),
                webdriver.JavascriptEnabled(true),
                webdriver.HandlesAlerts(true),
                webdriver.Rotatable(true),
                webdriver.CustomCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"),
                webdriver.CustomCapability("phantomjs.page.customHeaders.Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"),
                webdriver.CustomCapability("phantomjs.page.customHeaders.Accept-Language", "ru-RU"),
        )

        session, err := wd.Connect("http://127.0.0.1:4444")
        if err != nil {
                panic(err)
        }

        defer session.Close()

        if _, err = session.WindowSize(2048, 1680); err != nil {
                panic(err)
        }
        if _, err = session.Url("http://httpbin.org/headers"); err != nil {
                panic(err)
        }

        if r, err := session.Screenshot(); err != nil {
                panic(err)
        } else {
                w, _ := os.Create("screenshot.png")
                defer w.Close()

                io.Copy(w, r)
        }
}

Testing

go test

References

Contributors

Remco Verhoef

Copyright and license

Code and documentation copyright 2011-2016 Remco Verhoef.

Code released under the MIT license. ~

Something went wrong with that request. Please try again.