Skip to content

Commit

Permalink
update examples for docker and remote connection (#307)
Browse files Browse the repository at this point in the history
* update examples for docker and remote connection

* update

Co-authored-by: Ivan Grishaev <[email protected]>
  • Loading branch information
Uunnamed and igrishaev authored Aug 25, 2020
1 parent 6a28edd commit c37fbc5
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,29 +730,18 @@ respectively:

## Connection to remote webdriver

To create a connection with an existing webdriver, you must first create the driver manually.
Example:
To connect to a driver already running on a local or remote host, you must specify the `:host` parameter
which might be either a hostname (localhost, some.remote.host.net) or an IP address (127.0.0.1, 183.102.156.31) and the `:port`.
If the port is not specified, the default port is set.

```clojure
;; Chrome
(def driver (create-driver :chrome {:host "127.0.0.1" :port 9515})) ;; 127.0.0.1 is default host, use own

;; Firefox
(def driver (create-driver :firefox {:host "127.0.0.1" :port 4444}))
```

Then pass the `capabilities` to the browser with `chromeOptions` or `:moz:firefoxOptions` for Chrome or Firefox respectively:
Example:

```clojure
;; Chrome
(connect-driver driver
{:capabilities
{:chromeOptions {:args ["--no-sandbox" "--headless"]}}})
(def driver (chrome {:host "127.0.0.1" :port 9515})) ;; for connection to driver on localhost on port 9515

;; Firefox
(connect-driver driver
{:capabilities
{:moz:firefoxOptions {:args ["--headless"]}}})
(def driver (firefox {:host "192.168.1.11"})) ;; the default port for firefox is 4444
```

## Webdriver in Docker
Expand All @@ -770,11 +759,13 @@ for [Firefox](https://hub.docker.com/r/instrumentisto/geckodriver):
```
docker run --name geckodriver -p 4444:4444 -d instrumentisto/geckodriver
```
to connect to the driver you just need to specify the port on which it is running

To connect to the driver you just need to specify the `:host` parameter as `localhost` or `127.0.0.1` and the `:port` on which it is running.
If the port is not specified, the default port is set.

``` clojure
(def driver (chrome-headless {:port 9515 :args ["--no-sandbox"]}))
(def driver (firefox-headless {:port 4444}))
(def driver (chrome-headless {:host "localhost" :port 9515 :args ["--no-sandbox"]}))
(def driver (firefox-headless {:host "localhost"})) ;; will try to connect to port 4444
```

## HTTP Proxy
Expand Down

0 comments on commit c37fbc5

Please sign in to comment.