Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 21eeb7f

Browse files
Add docs for download-paths
Adding documentation that explains how to specify a directory from which tests can now download files that were downloaded by them on the node.
1 parent 761a3ad commit 21eeb7f

File tree

8 files changed

+366
-0
lines changed

8 files changed

+366
-0
lines changed

‎website_and_docs/content/documentation/grid/configuration/cli_options.en.md‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pull request updating this page.
224224
| `--drain-after-session-count`| int | `1` | Drain and shutdown the Node after X sessions have been executed. Useful for environments like Kubernetes. A value higher than zero enables this feature. |
225225
| `--hub`| string | `http://localhost:4444` | The address of the Hub in a Hub-and-Node configuration. Can be a hostname or IP address (`hostname`), in which case the Hub will be assumed to be `http://hostname:4444`, the `--grid-url` will be the same `--publish-events` will be `tcp://hostname:4442` and `--subscribe-events` will be `tcp://hostname:4443`. If `hostname` contains a port number, that will be used for `--grid-url` but the URIs for the event bus will remain the same. Any of these default values may be overridden but setting the correct flags. If the hostname has a protocol (such as `https`) that will be used too. |
226226
| `--enable-cdp`| boolean | `true` | Enable CDP proxying in Grid. A Grid admin can disable CDP if the network doesnot allow websockets. True by default. |
227+
| `--downloads-path`| string | `/usr/downloads` | The default location wherein all browser triggered file downloads would be available to be retrieved from. This is usually the directory that you configure in your browser as the default location for storing downloaded files. |
227228

228229
### Relay
229230

@@ -349,3 +350,50 @@ driver.quit();
349350
```
350351

351352
Set the custom capability to `false` in order to match the Node B.
353+
354+
#### Specifying path from where downloaded files can be retrieved
355+
356+
At times a test may need to access files that were downloaded by it on the Node. To retrieve such files, following can be done.
357+
358+
##### Start the Hub
359+
```
360+
java -jar selenium-server-<version>.jar hub
361+
```
362+
363+
##### Start the Node with downloads path specified
364+
```
365+
java -jar selenium-server-<version>.jar node --downloads-path /usr/downloads
366+
```
367+
368+
##### Sample that retrieves the downloaded file
369+
370+
```java
371+
// The file can be downloaded by accessing
372+
// curl -X GET "http://localhost:4444/session/<sessionId>/se/file?filename=my_file.pdf"
373+
374+
HttpRequest request = new HttpRequest(
375+
HttpMethod.GET,
376+
String.format("/session/%s/se/file", driver.getSessionId()));
377+
request.addQueryParameter("filename", "my_appointments-1.pdf");
378+
// Here gridUrl is http://localhost:4444
379+
try (HttpClient client = HttpClient.Factory.createDefault().createClient(gridUrl)) {
380+
HttpResponse response = client.execute(request);
381+
Map<String, Object> map = new Json().toType(string(response), Json.MAP_TYPE);
382+
// The returned map would contain 2 keys viz.,
383+
// filename - This represents the name of the file (same as what was provided by the test)
384+
// contents - Base64 encoded String which contains the zipped file.
385+
String encodedContents = map.get("contents").toString();
386+
387+
//The file contents would always be a zip file and has to be unzipped.
388+
Zip.unzip(encodedContents, dirToCopyTo);
389+
}
390+
```
391+
392+
##### Points to remember:
393+
394+
* The endpoint to `GET` from is `/session/<sessionId>/se/file?filename=`
395+
* The response contains two keys viz.,
396+
* `filename` - Same as what was specified in the request.
397+
* `contents` - Base64 encoded zipped contents of the file.
398+
* The file contents are Base64 encoded.
399+
* The contents need to be unzipped.

‎website_and_docs/content/documentation/grid/configuration/cli_options.ja.md‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ Grid の設定には、さまざまなセクションが用意されています
223223
| `--drain-after-session-count` | int | `1` | X 個のセッションが実行された後に、ノードをドレインしてシャットダウンします。 Kubernetes のような環境で有用です。 0 より大きい値を指定すると、この機能が有効になります。 |
224224
| `--hub` | string | `http://localhost:4444` | ハブ・ノード構成におけるハブのアドレスを指定します。ホスト名か IP アドレスが指定できます。この場合、ハブは `http://hostname:4444` とみなされ、 `--grid-url` は同じものになります。 `--publish-events` は `tcp://hostname:4442` 、`--subscribe-events` は `tcp://hostname:4443` となります。 `hostname` にポート番号が含まれている場合は、それが `--grid-url` に使用されますが、イベントバスの URI は変更されません。これらのデフォルト値は、適切なフラグを設定することでオーバーライドすることができます。ホスト名にプロトコル(`https`のような)が含まれる場合もそれが利用されます。 |
225225
| `--enable-cdp` | boolean | `true` | Grid 内で CDP プロキシーを有効にします。もしネットワークが web socket を許可していない場合、Grid 管理者は CDP を無効にできます。デフォルトは true です。 |
226+
| `--downloads-path`| string | `/usr/downloads` | The default location wherein all browser triggered file downloads would be available to be retrieved from. This is usually the directory that you configure in your browser as the default location for storing downloaded files. |
226227

227228
### Relay
228229

@@ -349,3 +350,51 @@ driver.quit();
349350
```
350351

351352
ノード B とマッチさせるにはカスタム capability を `false` に設定します。
353+
354+
355+
#### Specifying path from where downloaded files can be retrieved
356+
357+
At times a test may need to access files that were downloaded by it on the Node. To retrieve such files, following can be done.
358+
359+
##### Start the Hub
360+
```
361+
java -jar selenium-server-<version>.jar hub
362+
```
363+
364+
##### Start the Node with downloads path specified
365+
```
366+
java -jar selenium-server-<version>.jar node --downloads-path /usr/downloads
367+
```
368+
369+
##### Sample that retrieves the downloaded file
370+
371+
```java
372+
// The file can be downloaded by accessing
373+
// curl -X GET "http://localhost:4444/session/<sessionId>/se/file?filename=my_file.pdf"
374+
375+
HttpRequest request = new HttpRequest(
376+
HttpMethod.GET,
377+
String.format("/session/%s/se/file", driver.getSessionId()));
378+
request.addQueryParameter("filename", "my_appointments-1.pdf");
379+
// Here gridUrl is http://localhost:4444
380+
try (HttpClient client = HttpClient.Factory.createDefault().createClient(gridUrl)) {
381+
HttpResponse response = client.execute(request);
382+
Map<String, Object> map = new Json().toType(string(response), Json.MAP_TYPE);
383+
// The returned map would contain 2 keys viz.,
384+
// filename - This represents the name of the file (same as what was provided by the test)
385+
// contents - Base64 encoded String which contains the zipped file.
386+
String encodedContents = map.get("contents").toString();
387+
388+
//The file contents would always be a zip file and has to be unzipped.
389+
Zip.unzip(encodedContents, dirToCopyTo);
390+
}
391+
```
392+
393+
##### Points to remember:
394+
395+
* The endpoint to `GET` from is `/session/<sessionId>/se/file?filename=`
396+
* The response contains two keys viz.,
397+
* `filename` - Same as what was specified in the request.
398+
* `contents` - Base64 encoded zipped contents of the file.
399+
* The file contents are Base64 encoded.
400+
* The contents need to be unzipped.

‎website_and_docs/content/documentation/grid/configuration/cli_options.pt-br.md‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ e esteja à vontade para nos enviar um pull request com alterações a esta pág
226226
| `--drain-after-session-count`| int | `1` | Drain and shutdown the Node after X sessions have been executed. Useful for environments like Kubernetes. A value higher than zero enables this feature. |
227227
| `--hub`| string | `http://localhost:4444` | The address of the Hub in a Hub-and-Node configuration. Can be a hostname or IP address (`hostname`), in which case the Hub will be assumed to be `http://hostname:4444`, the `--grid-url` will be the same `--publish-events` will be `tcp://hostname:4442` and `--subscribe-events` will be `tcp://hostname:4443`. If `hostname` contains a port number, that will be used for `--grid-url` but the URIs for the event bus will remain the same. Any of these default values may be overridden but setting the correct flags. If the hostname has a protocol (such as `https`) that will be used too. |
228228
| `--enable-cdp`| boolean | `true` | Enable CDP proxying in Grid. A Grid admin can disable CDP if the network doesnot allow websockets. True by default. |
229+
| `--downloads-path`| string | `/usr/downloads` | The default location wherein all browser triggered file downloads would be available to be retrieved from. This is usually the directory that you configure in your browser as the default location for storing downloaded files. |
230+
229231

230232
### Relay
231233

@@ -351,3 +353,51 @@ driver.quit();
351353
```
352354

353355
Set the custom capability to `false` in order to match the Node B.
356+
357+
358+
#### Specifying path from where downloaded files can be retrieved
359+
360+
At times a test may need to access files that were downloaded by it on the Node. To retrieve such files, following can be done.
361+
362+
##### Start the Hub
363+
```
364+
java -jar selenium-server-<version>.jar hub
365+
```
366+
367+
##### Start the Node with downloads path specified
368+
```
369+
java -jar selenium-server-<version>.jar node --downloads-path /usr/downloads
370+
```
371+
372+
##### Sample that retrieves the downloaded file
373+
374+
```java
375+
// The file can be downloaded by accessing
376+
// curl -X GET "http://localhost:4444/session/<sessionId>/se/file?filename=my_file.pdf"
377+
378+
HttpRequest request = new HttpRequest(
379+
HttpMethod.GET,
380+
String.format("/session/%s/se/file", driver.getSessionId()));
381+
request.addQueryParameter("filename", "my_appointments-1.pdf");
382+
// Here gridUrl is http://localhost:4444
383+
try (HttpClient client = HttpClient.Factory.createDefault().createClient(gridUrl)) {
384+
HttpResponse response = client.execute(request);
385+
Map<String, Object> map = new Json().toType(string(response), Json.MAP_TYPE);
386+
// The returned map would contain 2 keys viz.,
387+
// filename - This represents the name of the file (same as what was provided by the test)
388+
// contents - Base64 encoded String which contains the zipped file.
389+
String encodedContents = map.get("contents").toString();
390+
391+
//The file contents would always be a zip file and has to be unzipped.
392+
Zip.unzip(encodedContents, dirToCopyTo);
393+
}
394+
```
395+
396+
##### Points to remember:
397+
398+
* The endpoint to `GET` from is `/session/<sessionId>/se/file?filename=`
399+
* The response contains two keys viz.,
400+
* `filename` - Same as what was specified in the request.
401+
* `contents` - Base64 encoded zipped contents of the file.
402+
* The file contents are Base64 encoded.
403+
* The contents need to be unzipped.

‎website_and_docs/content/documentation/grid/configuration/cli_options.zh-cn.md‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ pull request updating this page.
233233
| `--drain-after-session-count`| int | `1` | Drain and shutdown the Node after X sessions have been executed. Useful for environments like Kubernetes. A value higher than zero enables this feature. |
234234
| `--hub`| string | `http://localhost:4444` | The address of the Hub in a Hub-and-Node configuration. Can be a hostname or IP address (`hostname`), in which case the Hub will be assumed to be `http://hostname:4444`, the `--grid-url` will be the same `--publish-events` will be `tcp://hostname:4442` and `--subscribe-events` will be `tcp://hostname:4443`. If `hostname` contains a port number, that will be used for `--grid-url` but the URIs for the event bus will remain the same. Any of these default values may be overridden but setting the correct flags. If the hostname has a protocol (such as `https`) that will be used too. |
235235
| `--enable-cdp`| boolean | `true` | Enable CDP proxying in Grid. A Grid admin can disable CDP if the network doesnot allow websockets. True by default. |
236+
| `--downloads-path`| string | `/usr/downloads` | The default location wherein all browser triggered file downloads would be available to be retrieved from. This is usually the directory that you configure in your browser as the default location for storing downloaded files. |
236237

237238
### Relay
238239

@@ -358,3 +359,50 @@ driver.quit();
358359
```
359360

360361
Set the custom capability to `false` in order to match the Node B.
362+
363+
#### Specifying path from where downloaded files can be retrieved
364+
365+
At times a test may need to access files that were downloaded by it on the Node. To retrieve such files, following can be done.
366+
367+
##### Start the Hub
368+
```
369+
java -jar selenium-server-<version>.jar hub
370+
```
371+
372+
##### Start the Node with downloads path specified
373+
```
374+
java -jar selenium-server-<version>.jar node --downloads-path /usr/downloads
375+
```
376+
377+
##### Sample that retrieves the downloaded file
378+
379+
```java
380+
// The file can be downloaded by accessing
381+
// curl -X GET "http://localhost:4444/session/<sessionId>/se/file?filename=my_file.pdf"
382+
383+
HttpRequest request = new HttpRequest(
384+
HttpMethod.GET,
385+
String.format("/session/%s/se/file", driver.getSessionId()));
386+
request.addQueryParameter("filename", "my_appointments-1.pdf");
387+
// Here gridUrl is http://localhost:4444
388+
try (HttpClient client = HttpClient.Factory.createDefault().createClient(gridUrl)) {
389+
HttpResponse response = client.execute(request);
390+
Map<String, Object> map = new Json().toType(string(response), Json.MAP_TYPE);
391+
// The returned map would contain 2 keys viz.,
392+
// filename - This represents the name of the file (same as what was provided by the test)
393+
// contents - Base64 encoded String which contains the zipped file.
394+
String encodedContents = map.get("contents").toString();
395+
396+
//The file contents would always be a zip file and has to be unzipped.
397+
Zip.unzip(encodedContents, dirToCopyTo);
398+
}
399+
```
400+
401+
##### Points to remember:
402+
403+
* The endpoint to `GET` from is `/session/<sessionId>/se/file?filename=`
404+
* The response contains two keys viz.,
405+
* `filename` - Same as what was specified in the request.
406+
* `contents` - Base64 encoded zipped contents of the file.
407+
* The file contents are Base64 encoded.
408+
* The contents need to be unzipped.

‎website_and_docs/content/documentation/grid/configuration/toml_options.en.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,44 @@ driver.get("https://selenium.dev");
188188
driver.quit();
189189
```
190190

191+
### Retrieving downloaded files from Node.
191192

193+
To be able to retrieve the files that were downloaded by a test at the Node, its location can be specified as below:
194+
195+
```toml
196+
[node]
197+
downloads-path = "/usr/downloads"
198+
```
199+
200+
Here is a Java example showing how to retrieve the file from Node.
201+
202+
```java
203+
// The file can be downloaded by accessing
204+
// curl -X GET "http://localhost:4444/session/<sessionId>/se/file?filename=my_file.pdf"
205+
206+
HttpRequest request = new HttpRequest(
207+
HttpMethod.GET,
208+
String.format("/session/%s/se/file", driver.getSessionId()));
209+
request.addQueryParameter("filename", "my_appointments-1.pdf");
210+
// Here gridUrl is http://localhost:4444
211+
try (HttpClient client = HttpClient.Factory.createDefault().createClient(gridUrl)) {
212+
HttpResponse response = client.execute(request);
213+
Map<String, Object> map = new Json().toType(string(response), Json.MAP_TYPE);
214+
// The returned map would contain 2 keys viz.,
215+
// filename - This represents the name of the file (same as what was provided by the test)
216+
// contents - Base64 encoded String which contains the zipped file.
217+
String encodedContents = map.get("contents").toString();
218+
219+
//The file contents would always be a zip file and has to be unzipped.
220+
Zip.unzip(encodedContents, dirToCopyTo);
221+
}
222+
```
223+
224+
##### Points to remember:
225+
226+
* The endpoint to `GET` from is `/session/<sessionId>/se/file?filename=`
227+
* The response contains two keys viz.,
228+
* `filename` - Same as what was specified in the request.
229+
* `contents` - Base64 encoded zipped contents of the file.
230+
* The file contents are Base64 encoded.
231+
* The contents need to be unzipped.

‎website_and_docs/content/documentation/grid/configuration/toml_options.ja.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,46 @@ WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444"), options
185185
driver.get("https://selenium.dev");
186186
driver.quit();
187187
```
188+
189+
### Retrieving downloaded files from Node.
190+
191+
To be able to retrieve the files that were downloaded by a test at the Node, its location can be specified as below:
192+
193+
194+
```toml
195+
[node]
196+
downloads-path = "/usr/downloads"
197+
```
198+
199+
Here is a Java example showing how to retrieve the file from Node.
200+
201+
```java
202+
// The file can be downloaded by accessing
203+
// curl -X GET "http://localhost:4444/session/<sessionId>/se/file?filename=my_file.pdf"
204+
205+
HttpRequest request = new HttpRequest(
206+
HttpMethod.GET,
207+
String.format("/session/%s/se/file", driver.getSessionId()));
208+
request.addQueryParameter("filename", "my_appointments-1.pdf");
209+
// Here gridUrl is http://localhost:4444
210+
try (HttpClient client = HttpClient.Factory.createDefault().createClient(gridUrl)) {
211+
HttpResponse response = client.execute(request);
212+
Map<String, Object> map = new Json().toType(string(response), Json.MAP_TYPE);
213+
// The returned map would contain 2 keys viz.,
214+
// filename - This represents the name of the file (same as what was provided by the test)
215+
// contents - Base64 encoded String which contains the zipped file.
216+
String encodedContents = map.get("contents").toString();
217+
218+
//The file contents would always be a zip file and has to be unzipped.
219+
Zip.unzip(encodedContents, dirToCopyTo);
220+
}
221+
```
222+
223+
##### Points to remember:
224+
225+
* The endpoint to `GET` from is `/session/<sessionId>/se/file?filename=`
226+
* The response contains two keys viz.,
227+
* `filename` - Same as what was specified in the request.
228+
* `contents` - Base64 encoded zipped contents of the file.
229+
* The file contents are Base64 encoded.
230+
* The contents need to be unzipped.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /