Giter Club home page Giter Club logo

selenium's Introduction

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.

selenium's People

Contributors

bcspragu avatar benknigge avatar crantok avatar crazcalm avatar donny-son avatar drmarcii avatar edef1c avatar fodpeter avatar hexcles avatar hkeide avatar hnakamur avatar jmhodges avatar jucasansao avatar llonchj avatar minusnine avatar nveeser avatar r-shestilovski avatar ramblex avatar ravitezu avatar rtm7777 avatar serge1peshcoff avatar skunkworker avatar tebeka avatar tekkamanendless avatar tinyshrimp avatar vishnukarthikl avatar x-xymos avatar xemoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

selenium's Issues

Handle client-side binding better

Newfangled web frameworks like Web Components and Angular do client-side binding of data such that an element exists in the DOM but doesn't have its content loaded yet, which happens asynchronously.

Using FindElement for such an element is not useful because the element already exists, but does not contain the data the tester is expecting. Testers then insert a time.Sleep call before the FindElement to allow the binding to happen.

Maybe we could do something better by offering a nicer API.

First, we should demonstrate the problem using a simple test case.

Add context.Context support

Go has a (relatively new) package, context, "which carries deadlines, cancelation signals, and other request-scoped values across API boundaries."

We should add support for passing a context into the API.

Making this backwards compatible and also be a usable API is tricky. All new functions should take a context.Context value as their first parameter. Augmenting an existing API usually involves allowing the caller to set a context value in a separate call to the existing API call, and then migrating all users to a new API that takes the context value explicitly.

Unable to modify the Firefox profile

I'd like to be able to modify the firefox profile being used in order to add some custom configuration to the browser behaviour but I'm having difficulty understanding how to do this.
Please could you add an example of how to go about this? Many thanks.

(Dave Dexter in bitbucket issue 10)

Invalid proxy settings

tebeka/selenium version 0.9.2
selenium-server version 3.0.1 and 2.53.1
firefox version 49.0.1

Code specified inside the proxy is invalid, firefox network options display "system settings.".
Tested python version, the agent can work properly.

I checked the information in the afternoon did not determine what the problem is, how should the agent should be installed?

package main

import (
    "fmt"

    "github.com/tebeka/selenium"
)

func main() {
    proxy := selenium.Proxy{
        Type:  "manual",
        SOCKS: "107.172.253.236:1080",
    }

    caps := selenium.Capabilities{
        "browserName": "firefox",
        "proxy":       proxy,
    }

    /*  The same invalid
        caps := selenium.Capabilities{
            "browserName": "firefox",
            "webdriver.gecko.driver": "",
            "proxy": map[string]interface{}{
                "proxyType":"manual",
                "httpProxy": "http://1.2.3.4:999",
                // etc.
            },
        }

    */

    wd, _ := selenium.NewRemote(caps, "")
    _ = wd

    fmt.Println("aaaaaaaa")

    //defer wd.Quit()

}

selenium-server log
Also tested 3.0.1, the same can not set the agent

D:\>java -jar selenium-server-standalone-2.53.1.jar
20:47:53.885 INFO - Launching a standalone Selenium Server
20:47:53.993 INFO - Java: Oracle Corporation 25.111-b14
20:47:53.993 INFO - OS: Windows 10 10.0 x86
20:47:54.004 INFO - v2.53.1, with Core v2.53.1. Built from revision a36b8b1
20:47:54.070 INFO - Driver class not found: com.opera.core.systems.OperaDriver
20:47:54.070 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
20:47:54.080 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN10
20:47:54.081 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
20:47:54.082 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
20:47:54.243 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
20:47:54.243 INFO - Selenium Server is up and running
20:48:00.525 INFO - Executing: [new session: Capabilities [{proxy={proxyType=manual, socksProxy=107.172.253.236:1080}, browserName=firefox}]])
20:48:00.551 INFO - Creating a new session for Capabilities [{proxy={proxyType=manual, socksProxy=107.172.253.236:1080}, browserName=firefox}]
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
ID":"ZeuCFoW-X82Y","location":"app-global","version":"49.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1474592003179,"updateDate":1474592003179,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"49.0.1","maxVersion":"49.0.1"}],"targetPlatforms":[],"seen":true}
1477140481755   addons.xpi      DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1477140481756   DeferredSave.extensions.json    DEBUG   Save changes
1477140481757   addons.xpi      DEBUG   Updating database with changes to installed add-ons
1477140481757   addons.xpi-utils        DEBUG   Updating add-on states
1477140481758   addons.xpi-utils        DEBUG   Writing add-ons list
1477140481763   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481764   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.2
1477140481764   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481765   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.0.4
1477140481766   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481766   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.0
1477140481768   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
1477140481768   addons.manager  DEBUG   Provider finished startup: XPIProvider
1477140481768   addons.manager  DEBUG   Starting provider: LightweightThemeManager
1477140481768   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
1477140481768   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
1477140481769   addons.manager  DEBUG   Starting provider: GMPProvider
1477140481778   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
1477140481778   addons.manager  DEBUG   Provider finished startup: GMPProvider
1477140481778   addons.manager  DEBUG   Starting provider: PluginProvider
1477140481779   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
1477140481779   addons.manager  DEBUG   Provider finished startup: PluginProvider
1477140481779   addons.manager  DEBUG   Completed startup sequence
1477140482233   addons.manager  DEBUG   Starting provider: <unnamed-provider>
1477140482233   addons.manager  DEBUG   Registering shutdown blocker for <unnamed-provider>
1477140482234   addons.manager  DEBUG   Provider finished startup: <unnamed-provider>
1477140482237   DeferredSave.extensions.json    DEBUG   Starting write
1477140482495   addons.repository       DEBUG   No addons.json found.
1477140482496   DeferredSave.addons.json        DEBUG   Save changes
1477140482500   DeferredSave.addons.json        DEBUG   Starting timer
1477140482572   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
1477140482573   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
1477140482573   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider
1477140482577   DeferredSave.extensions.json    DEBUG   Write succeeded
1477140482578   addons.xpi-utils        DEBUG   XPI Database saved, setting schema version preference to 17
1477140482580   DeferredSave.addons.json        DEBUG   Starting write
1477140482608   DeferredSave.addons.json        DEBUG   Write succeeded

        at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:112)
        at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:129)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.openqa.selenium.remote.server.FirefoxDriverProvider.callConstructor(FirefoxDriverProvider.java:91)
        at org.openqa.selenium.remote.server.FirefoxDriverProvider.newInstance(FirefoxDriverProvider.java:68)
        at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
        at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
        at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
20:48:47.089 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-OQVJ62N', ip: '169.254.159.21', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: unknown
        at java.util.concurrent.FutureTask.report(Unknown Source)
        at java.util.concurrent.FutureTask.get(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
        at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)
        at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
        at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124)
        at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
        at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
        at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
        at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:79)
        at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:204)
        at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
        at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
        at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
        at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
        at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
        at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
        at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
        at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
        at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
        at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-OQVJ62N', ip: '169.254.159.21', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: unknown
        at org.openqa.selenium.remote.server.FirefoxDriverProvider.callConstructor(FirefoxDriverProvider.java:101)
        at org.openqa.selenium.remote.server.FirefoxDriverProvider.newInstance(FirefoxDriverProvider.java:68)
        at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
        at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
        at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.openqa.selenium.remote.server.FirefoxDriverProvider.callConstructor(FirefoxDriverProvider.java:91)
        ... 9 more
Caused by: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows:
ID":"ZeuCFoW-X82Y","location":"app-global","version":"49.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1474592003179,"updateDate":1474592003179,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"49.0.1","maxVersion":"49.0.1"}],"targetPlatforms":[],"seen":true}
1477140481755   addons.xpi      DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1477140481756   DeferredSave.extensions.json    DEBUG   Save changes
1477140481757   addons.xpi      DEBUG   Updating database with changes to installed add-ons
1477140481757   addons.xpi-utils        DEBUG   Updating add-on states
1477140481758   addons.xpi-utils        DEBUG   Writing add-ons list
1477140481763   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481764   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.2
1477140481764   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481765   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.0.4
1477140481766   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481766   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.0
1477140481768   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
1477140481768   addons.manager  DEBUG   Provider finished startup: XPIProvider
1477140481768   addons.manager  DEBUG   Starting provider: LightweightThemeManager
1477140481768   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
1477140481768   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
1477140481769   addons.manager  DEBUG   Starting provider: GMPProvider
1477140481778   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
1477140481778   addons.manager  DEBUG   Provider finished startup: GMPProvider
1477140481778   addons.manager  DEBUG   Starting provider: PluginProvider
1477140481779   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
1477140481779   addons.manager  DEBUG   Provider finished startup: PluginProvider
1477140481779   addons.manager  DEBUG   Completed startup sequence
1477140482233   addons.manager  DEBUG   Starting provider: <unnamed-provider>
1477140482233   addons.manager  DEBUG   Registering shutdown blocker for <unnamed-provider>
1477140482234   addons.manager  DEBUG   Provider finished startup: <unnamed-provider>
1477140482237   DeferredSave.extensions.json    DEBUG   Starting write
1477140482495   addons.repository       DEBUG   No addons.json found.
1477140482496   DeferredSave.addons.json        DEBUG   Save changes
1477140482500   DeferredSave.addons.json        DEBUG   Starting timer
1477140482572   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
1477140482573   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
1477140482573   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider
1477140482577   DeferredSave.extensions.json    DEBUG   Write succeeded
1477140482578   addons.xpi-utils        DEBUG   XPI Database saved, setting schema version preference to 17
1477140482580   DeferredSave.addons.json        DEBUG   Starting write
1477140482608   DeferredSave.addons.json        DEBUG   Write succeeded

Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-OQVJ62N', ip: '169.254.159.21', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: FirefoxDriver
        at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:124)
        at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:129)
        ... 14 more
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
ID":"ZeuCFoW-X82Y","location":"app-global","version":"49.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1474592003179,"updateDate":1474592003179,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"49.0.1","maxVersion":"49.0.1"}],"targetPlatforms":[],"seen":true}
1477140481755   addons.xpi      DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1477140481756   DeferredSave.extensions.json    DEBUG   Save changes
1477140481757   addons.xpi      DEBUG   Updating database with changes to installed add-ons
1477140481757   addons.xpi-utils        DEBUG   Updating add-on states
1477140481758   addons.xpi-utils        DEBUG   Writing add-ons list
1477140481763   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481764   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.2
1477140481764   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481765   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.0.4
1477140481766   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481766   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.0
1477140481768   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
1477140481768   addons.manager  DEBUG   Provider finished startup: XPIProvider
1477140481768   addons.manager  DEBUG   Starting provider: LightweightThemeManager
1477140481768   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
1477140481768   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
1477140481769   addons.manager  DEBUG   Starting provider: GMPProvider
1477140481778   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
1477140481778   addons.manager  DEBUG   Provider finished startup: GMPProvider
1477140481778   addons.manager  DEBUG   Starting provider: PluginProvider
1477140481779   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
1477140481779   addons.manager  DEBUG   Provider finished startup: PluginProvider
1477140481779   addons.manager  DEBUG   Completed startup sequence
1477140482233   addons.manager  DEBUG   Starting provider: <unnamed-provider>
1477140482233   addons.manager  DEBUG   Registering shutdown blocker for <unnamed-provider>
1477140482234   addons.manager  DEBUG   Provider finished startup: <unnamed-provider>
1477140482237   DeferredSave.extensions.json    DEBUG   Starting write
1477140482495   addons.repository       DEBUG   No addons.json found.
1477140482496   DeferredSave.addons.json        DEBUG   Save changes
1477140482500   DeferredSave.addons.json        DEBUG   Starting timer
1477140482572   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
1477140482573   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
1477140482573   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider
1477140482577   DeferredSave.extensions.json    DEBUG   Write succeeded
1477140482578   addons.xpi-utils        DEBUG   XPI Database saved, setting schema version preference to 17
1477140482580   DeferredSave.addons.json        DEBUG   Starting write
1477140482608   DeferredSave.addons.json        DEBUG   Write succeeded

        at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:112)
        ... 19 more
20:48:47.100 WARN - Exception: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
ID":"ZeuCFoW-X82Y","location":"app-global","version":"49.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1474592003179,"updateDate":1474592003179,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"49.0.1","maxVersion":"49.0.1"}],"targetPlatforms":[],"seen":true}
1477140481755   addons.xpi      DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1477140481756   DeferredSave.extensions.json    DEBUG   Save changes
1477140481757   addons.xpi      DEBUG   Updating database with changes to installed add-ons
1477140481757   addons.xpi-utils        DEBUG   Updating add-on states
1477140481758   addons.xpi-utils        DEBUG   Writing add-ons list
1477140481763   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481764   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.2
1477140481764   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481765   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.0.4
1477140481766   addons.xpi      DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1477140481766   addons.xpi      DEBUG   Calling bootstrap method startup on [email protected] version 1.0
1477140481768   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
1477140481768   addons.manager  DEBUG   Provider finished startup: XPIProvider
1477140481768   addons.manager  DEBUG   Starting provider: LightweightThemeManager
1477140481768   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
1477140481768   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
1477140481769   addons.manager  DEBUG   Starting provider: GMPProvider
1477140481778   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
1477140481778   addons.manager  DEBUG   Provider finished startup: GMPProvider
1477140481778   addons.manager  DEBUG   Starting provider: PluginProvider
1477140481779   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
1477140481779   addons.manager  DEBUG   Provider finished startup: PluginProvider
1477140481779   addons.manager  DEBUG   Completed startup sequence
1477140482233   addons.manager  DEBUG   Starting provider: <unnamed-provider>
1477140482233   addons.manager  DEBUG   Registering shutdown blocker for <unnamed-provider>
1477140482234   addons.manager  DEBUG   Provider finished startup: <unnamed-provider>
1477140482237   DeferredSave.extensions.json    DEBUG   Starting write
1477140482495   addons.repository       DEBUG   No addons.json found.
1477140482496   DeferredSave.addons.json        DEBUG   Save changes
1477140482500   DeferredSave.addons.json        DEBUG   Starting timer
1477140482572   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
1477140482573   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
1477140482573   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider
1477140482577   DeferredSave.extensions.json    DEBUG   Write succeeded
1477140482578   addons.xpi-utils        DEBUG   XPI Database saved, setting schema version preference to 17
1477140482580   DeferredSave.addons.json        DEBUG   Starting write
1477140482608   DeferredSave.addons.json        DEBUG   Write succeeded

20:51:49.214 INFO - Shutting down...

Remove the custom http.Client in remote.go

Back in the day, http.Client would not copy over request headers on redirects. This was fixed in Go 1.8:

https://golang.org/doc/go1.8#net_http

We create our own HTTP client to work around this issue, predating the above fix:

https://github.com/tebeka/selenium/blob/master/remote.go#L1278

While we're here, we should consider removing the GetHTTPClient function and just exporting the package-scoped httpClient variable. This is indeed an interface change, albeit a pretty minor one.

Remove the WebDriver interface and instead expose a concrete type

Large interfaces are discouraged in Go. Interfaces should be small (e.g. the io.* interfaces) and generally defined by the user of a type, not the API (unless there are going to be multiple implementations of the interface within the package).

We should consider removing the large interface type and simply expose the underlying concrete type. This is an API incompatible change. First, we'd have to expose the underlying type and maintain the interface for a while, until callers can migrate to the new API, and then remove the interface.

Consider doing this with #71, which also requires API breakage.

Kill all webDriver sessions

Hello.
Need help with some questions on your lib.
Is there a way to kill running browser from previous session?
If last session wasn't terminated by wd.Quit() - I see browser instance stay in memory and next run just create and kill new session without any affect on old one.
I found this link http://stackoverflow.com/questions/15067107/difference-between-webdriver-dispose-close-and-quit
but don't know how to use Webdriver.Dispose() (If i'm right I need this command).

Thanks for you work. I'm glad to use it.

Chrome Profile?

How can i start chrome with arguments ? or create a chrome profile?

Expand t.Fatal(err) to include more debugging information

Go style best practices dictate that test failures should be useful.

https://github.com/golang/go/wiki/CodeReviewComments#useful-test-failures

In most cases, the error message should include:

  • The function that failed.
  • The inputs to the function.
  • The output of the function
  • For at least non-error types, the expected value.

We should audit and expand the errors in remote_test.go to ensure each failure is handled. In particular, the errors like:

title, err := wd.Title()
if err != nil {
  t.Fatal(err)
}

Should be expanded like:

title, err := wd.Title()
if err != nil {
  t.Fatalf("wd.Title() returned error: %v", err)
}

selenium.ByXPATH is broken

Suppose we have a website like:

<div class="box">
  <div class="word">
    <a href="I_NEED_THIS_VALUE">foo</a>
  </div>
</div>
<div class="box">
...
</div>
<div class="box">
...
</div>

I scrape box elements like so:

    elements, err := wd.FindElements(selenium.ByClassName, "box")
    panicIf(err)

    for _, element := range elements {
        el, err := element.FindElement(selenium.ByXPATH, "//div[contains(@class,'word')]/a/@href")
}

I get the error that the element is invalid. If I try just //div[contains(@Class,'word')]/a, I will always get the first element in box div, not the first element of element. What can I do now?

(furion in bitbucket issue 11)

Run coverage analysis and add test

There are a handful of methods that aren't tested. We should run coverage analysis and add tests for those methods and other untested code.

go tool cover -html=count.out

Supply AppEngine Flexible Environment custom runtime

In your Readme.md you have information about AppEngine.
I believe it is useful, but I can't understand what it is and how can I use it.
Could you please share some use cases, some good examples?

Thank you :)

hi,when i use selenium,sometimes i delete cookies, it give me this,plz help

return self.view_functionsrule.endpoint
File "/root/git/user-profile-waimai-crawler/venv/lib64/python2.7/site-packages/flask_restful/init.py", line 477, in wrapper
resp = resource(*args, **kwargs)
File "/root/git/user-profile-waimai-crawler/venv/lib64/python2.7/site-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/root/git/user-profile-waimai-crawler/venv/lib64/python2.7/site-packages/flask_restful/init.py", line 587, in dispatch_request
resp = meth(*args, **kwargs)
File "/root/git/user-profile-waimai-crawler/venv/lib64/python2.7/site-packages/flask_httpauth.py", line 93, in decorated
return f(*args, **kwargs)
File "/root/git/user-profile-waimai-crawler/venv/lib64/python2.7/site-packages/flask_restful/init.py", line 679, in wrapper
resp = f(*args, **kwargs)
File "/root/git/test6/user-profile-waimai-crawler/api/resource.py", line 46, in post
result = self.platform_service.run_task(platform_id, user)
File "/root/git/test6/user-profile-waimai-crawler/service/platform_service.py", line 30, in run_task
auth = login_service.login_by_user_password(user)
File "/root/git/test6/user-profile-waimai-crawler/service/login_service.py", line 41, in login_by_user_password
browser.delete_all_cookies()
File "/root/git/user-profile-waimai-crawler/venv/lib64/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 685, in delete_all_cookies
self.execute(Command.DELETE_ALL_COOKIES)
File "/root/git/user-profile-waimai-crawler/venv/lib64/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 249, in execute
self.error_handler.check_response(response)
File "/root/git/user-profile-waimai-crawler/venv/lib64/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'e4a315d751a9', ip: '192.168.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.6.2.el7.x86_64', java.version: '1.8.0_121'
Driver info: driver.version: unknown

Timeout is not valid.

caps := selenium.Capabilities{"browserName": "firefox"}
wd, _ := selenium.NewRemote(caps, "")
defer wd.Quit()
wd.SetPageLoadTimeout(5000) //5s
wd.Get("http://xxxxxx")
span, _ := wd.FindElement(selenium.ByCSSSelector, ".pd-name")
fmt.Println(span.Text())

".pd - name " loaded, I will stop page continues to load.But set the timeout seems to have no effect.

Help me.

Thank you.

elem.SendKeys(code) not working - GoDoc Example

Hello,

I'm trying to run the code example from GoDoc.

// Run some code on play.golang.org and display the result
package main

import (
	"fmt"
	"time"

	"github.com/tebeka/selenium"
)

var code = `
package main
import "fmt"

func main() {
	fmt.Println("Hello WebDriver!\n")
}
`

// Errors are ignored for brevity.

func main() {
	// FireFox driver without specific version
	// *** Add gecko driver here if necessary (see notes above.) ***
	caps := selenium.Capabilities{"browserName": "firefox"}
	wd, err := selenium.NewRemote(caps, "")
	if err != nil {
		panic(err)
	}
	defer wd.Quit()

	// Get simple playground interface
	wd.Get("http://play.golang.org/?simple=1")

	// Enter code in textarea
	elem, _ := wd.FindElement(selenium.ByCSSSelector, "#code")
	elem.Clear()
	elem.SendKeys(code)

	// Click the run button
	btn, _ := wd.FindElement(selenium.ByCSSSelector, "#run")
	btn.Click()

	// Get the result
	div, _ := wd.FindElement(selenium.ByCSSSelector, "#output")

	output := ""
	// Wait for run to finish
	for {
		output, _ = div.Text()
		if output != "Waiting for remote server..." {
			break
		}
		time.Sleep(time.Millisecond * 100)
	}

	fmt.Printf("Got: %s\n", output)
}

The only difference is that I'm using chrome with selenium-server instead of firefox.

But it seems that when I run the example, the elem.SendKeys(code) function fails. Because nothing gets inserted into the text box and the result from the Playground is:

Got: can't load package: package main: 
tmp/sandbox573608783/main.go:1:1: expected 'package', found 'EOF'

Program exited.

Any ideas as to why it isn't inserting the code properly? Thanks.

Cannot set geckodriver in code

I'm sure I had this working when I submitted that pull request to update the docs. I've just come back to it after many weeks and now I can't get it to work.

This does work:

java -Dwebdriver.gecko.driver="/home/me/Downloads/geckodriver" \
  -jar ~/Downloads/selenium-server-standalone-3.0.1.jar

with

caps := selenium.Capabilities{
		"browserName":            "firefox",
}

This does not work:

java -jar ~/Downloads/selenium-server-standalone-3.0.1.jar

with

caps := selenium.Capabilities{
		"browserName":            "firefox",
		"webdriver.gecko.driver": "/home/me/Downloads/geckodriver",
}

It gives error:

The path to the driver executable must be set by the webdriver.gecko.driver \
system property; for more information, see https://github.com/mozilla/geckodriver. \
The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases

Improve testing speed: reduce number of calls to newRemote

We have segregated the tests into many small tests, which is good from an isolation perspective. However, a call to newRemote is very expensive; we should consider consolidating tests into subtests that share a WebDriver instance, especially those that don't modify state. This should reduce test run time.

Adding Proxy support

Hey I'm trying to use proxies and I noticed there wasn't support for it yet. I could implement it if you want I was just wondering if there was anything specific of how you wanted implemented.

Here is the selenium proxy manual
https://code.google.com/p/selenium/wiki/JsonWireProtocol#Proxy_JSON_Object

What I was thinking is just adding a simple Proxy struct

/* Proxy configuration. */
type Proxy struct {
    ProxyType          string `json:"proxyType"`
    ProxyAutoconfigURL string `json:"proxyAutoconfigUrl"`
    FTPProxy           string `json:"ftpProxy"`
    HTTPProxy          string `json:"httpProxy"`
    SSLProxy           string `json:"sslProxy"`
    SOCKSProxy         string `json:"socksProxy"`
    SOCKSUsername      string `json:"socksUsername"`
    SOCKSPassword      string `json:"socksPassword"`
    NoProxy            string `json:"noProxy"`
}

Then it can be passed in as an interface in capabilities. Something like:

caps := selenium.Capabilities{
"browserName": "firefox"
"proxy": selenium.Proxy
}

Add OS X to Travis CI testing

We currently only use Travis to ensure the tests pass using Linux (and Firefox). We should consider adding a OS X target as well.

(A separate issue will be filed for non-Firefox browsers).

Need to add support for W3C variant of WebDriver protocol

The W3C WebDriver spec is getting close to CR status, and some endpoints (notably GeckoDriver and EdgeDriver) will only support the new spec. There are some changes that will need to be made to this project to make it work as this transition is made, most notably:

  1. responses no longer include a status field. Instead they include an error field with a text value if an error occurs.

  2. The various low-level actions endpoints (e.g. keyboard and mouse actions) are no longer supported. Instead a single actions endpoint is defined that takes a message representing a sequence of keyboard, mouse, and touch screen actions.

Add Chrome to the Travis CI test

We currently only use Travis to ensure the tests pass using Firefox (on Linux; see #68). We should add Chrome into the automatic integration tests as well.

One concern is runtime: The Firefox tests already take a long time. The Chrome tests run much faster, but would still make the overall time longer. We should consider making tests run in parallel, to whatever extent possible, as part of this task.

Panic when going directly to Geckodriver 0.16+

Launched standalone Geckodriver binary and using this client to access it. Getting the following panic because of changed JSON protocol in Geckodriver:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x120c87d]

goroutine 36 [running]:
github.com/tebeka/selenium.(*remoteWD).NewSession(0xc42013e000, 0xc42013e000, 0xc42013a000, 0x13d80b0, 0xc420095778)
 /Users/aandryashin/go/src/github.com/tebeka/selenium/remote.go:334 +0x74d
github.com/tebeka/selenium.NewRemote(0xc420136000, 0x12a63fa, 0x1c, 0xc42013a088, 0xc420136000, 0x0, 0x0)
 /Users/aandryashin/go/src/github.com/tebeka/selenium/remote.go:207 +0xa7
main.openURL(0xc4200b02a0, 0x12a16f0, 0xd)
 /Users/aandryashin/go/src/github.com/aandryashin/seleniun-test/main.go:32 +0x155
created by main.main
 /Users/aandryashin/go/src/github.com/aandryashin/seleniun-test/main.go:22 +0x83

FindElement by LinkText is not working on non-latin text

I have a page like this:

<a href="">тест</a>

And code like

wd.FindElement(selenium.ByPartialLinkText, "тест")

will produce the no such element error. When using latin text everything is working as expected.

(Anonymous in bitbucket issue 12)

WebDriverWait Supprt

Implementing Explicit and Implicit Wait API. I will look into this myself and submit a PR.

Proxy example, please?

Hello!
What is JSON Proxy Object and how to create it and supply to Capabilities? Can you throw a little example, say I have proxy
http://1.2.3.4:5678

Sadly I lack any knowledge in JSON, I only Selenium to test some heavy Ajax content and I need to do it via proxies.

EDIT: Reading JSON and GO and asking question on stackoverflow, seems like just need to use map[string]interface{} like

caps := selenium.Capabilities{"browserName": "firefox", "proxy": map[string]interface{}{"proxyType": "manual", "httpProxy": "218.97.194.214:80"}}

Invalid memory address error

The following code produce the following error that shouldn't happen

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x80491b7]

goroutine 1 [running]:
panic(0x8248ba0, 0x1860c010)
    /usr/lib/go/src/runtime/panic.go:500 +0x331
main.main()
    /home/user/projects/selenium.go:12 +0x1b7
exit status 2

caps := selenium.Capabilities{"browserName": "firefox"}   
wd, _ := selenium.NewRemote(caps, "")
defer wd.Quit()
wd.Get("http://www.google.com")
elem, _ := wd.FindElement(selenium.ByName, "q")
elem.SendKeys("Working")
elem.Submit()

Add examples or tests for other selector types

I'm having a hard time selecting elements using ByCSSSelector or ByXPATH.
I suggest adding some examples to documentation, or unit tests.

(reported by jevonearth as bitbucket issue 8)

using a socks5 proxy

This may be me not understanding selenium correctly. But I'm trying to use a SOCKS5 proxy for my request. I tried doing this:

   dialSocksProxy, err := proxy.SOCKS5("tcp", "ipaddress:port", nil, proxy.Direct)
if err != nil {
    fmt.Println("Error connecting to proxy:", err)
}
tr := &http.Transport{Dial: dialSocksProxy.Dial}
selenium.GetHTTPClient().Transport = tr

Is there a different way to go about setting this?

Switch to alert box

Can you tell me how do I switch to alert box from driver? Something like this:

WebDriverWait wait = new WebDriverWait(driver, 2);
        wait.until(ExpectedConditions.alertIsPresent());
        Alert alert = driver.switchTo().alert();
        alert.accept();

There is driver.AcceptAlert() but this will not be able to get alert unless its switched to alert box.

Suggestion: Add help for gecko driver

As per instructions in doc.go, I downloaded the selenium standalone server. I obtained it from a different URL from the one given in doc.go (see my pull request.) The server was major version 3. I got the following error when calling selenium.NewRemote()

The path to the driver executable must be set by the webdriver.gecko.driver system property;
for more information, see https://github.com/mozilla/geckodriver.
The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases

To solve this, I downloaded a precompiled driver from

https://github.com/mozilla/geckodriver/releases

as instructed and added the path to that driver in my selenium.Capabilities instance

    caps := selenium.Capabilities{
        "browserName":            "firefox",
        "webdriver.gecko.driver": "/path/to/downloaded/geckodriver",
    }

The example in doc.go worked after that.

Pdeathsig cannot be used on Darwin

The 'Pdeathsig' of SysProcAttr struct only can be used on Linux, it will make compiling failure on macOS.

The error message as following

./service.go:118: unknown syscall.SysProcAttr field 'Pdeathsig' in struct literal
./service.go:200: unknown syscall.SysProcAttr field 'Pdeathsig' in struct literal

Please see SysProcAttr

Upgrading to Selenium WebDriver 3.4 broke enabling HTMLUnit's Javscript

--- FAIL: TestHTMLUnit (4.06s)
--- FAIL: TestHTMLUnit/ExecuteScript (1.95s)
remote_test.go:1102: unknown error: Javascript is not enabled for this HtmlUnitDriver instance
--- FAIL: TestHTMLUnit/ExecuteScriptOnElement (0.56s)
remote_test.go:1156: unknown error: Javascript is not enabled for this HtmlUnitDriver instance
--- FAIL: TestHTMLUnit/ExecuteScriptWithNilArgs (0.30s)
remote_test.go:1125: unknown error: Javascript is not enabled for this HtmlUnitDriver instance

Scroll to element

Hi,

I was wondering how to put an element in view,

I assumed using FindElement will scroll to the relevant element but using screenshot I see that won't work.

I also tried to use MoveTo(0,0) but it seems it's not scrolling as well.

What is the correct way to scroll to element?

Thanks,
@eranchetz

Explicit Waits?

Hey there! Working on transitioning some selenium tests I've written in Ruby to Go and I've used explicit waits quite a bit throughout the suite. In looking through the docs/code here, I've been unable to locate anything but updating the implicit wait time.

Is something yet to be implemented that I could help with, or are there particular reasons it hasn't/won't be? Is there any other implementation method for this type of selenium functionality that'd you recommend instead?

Thanks!

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.