Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update examples for docker and remote connection #307

Merged
merged 3 commits into from
Aug 25, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,29 +730,17 @@ 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 ip and port.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Немного точнее:

...you must specify a :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). When the port is not set, the default one gets used.

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 +758,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 as `localhost` and the port on which it is running.
If the port is not specified, the default port is set.

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

## HTTP Proxy
Expand Down