You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These are the requirements to create your own local dev environment to contribute to Selenium.
50
49
51
50
### All Platforms
51
+
52
52
*[Bazelisk](https://github.com/bazelbuild/bazelisk), a Bazel wrapper that automatically downloads
53
53
the version of Bazel specified in `.bazelversion` file and transparently passes through all
54
54
command-line arguments to the real Bazel binary.
@@ -58,11 +58,13 @@ These are the requirements to create your own local dev environment to contribut
58
58
installed. If you're met with a list of command-line options, you're referencing the JDK properly.
59
59
60
60
### MacOS
61
+
61
62
* Xcode including the command-line tools. Install the latest version using: `xcode-select --install`
62
63
* Rosetta for Apple Silicon Macs. Add `build --host_platform=//:rosetta` to the `.bazelrc.local` file. We are working
63
64
to make sure this isn't required in the long run.
64
65
65
66
### Windows
67
+
66
68
Several years ago [Jim Evans](https://www.linkedin.com/in/jimevansmusic/) published a great article on
67
69
[Setting Up a Windows Development Environment for the Selenium .NET Language Bindings](https://jimevansmusic.blogspot.com/2020/04/setting-up-windows-development.html);
68
70
This article is out of date, but it includes more detailed descriptions and screenshots that some people might find useful.
@@ -71,6 +73,7 @@ This article is out of date, but it includes more detailed descriptions and scre
71
73
<summary>Click to see Current Windows Setup Requirements</summary>
72
74
73
75
#### Option 1: Automatic Installation from Scratch
76
+
74
77
This script will ensure a complete ready to execute developer environment.
75
78
(nothing is installed or set that is already present unless otherwise prompted)
76
79
@@ -80,6 +83,7 @@ This script will ensure a complete ready to execute developer environment.
80
83
4. Download and execute this script in the powershell terminal: [scripts/dev-environment-setup.ps1]`
81
84
82
85
#### Option 2: Manual Installation
86
+
83
87
1. Allow running scripts in Selenium in general:
84
88
```
85
89
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
@@ -158,26 +162,29 @@ The Bazel documentation has a [handy guide](https://bazel.build/run/build#specif
158
162
for various shortcuts and all the ways to build multiple targets, which Selenium makes frequent use of.
159
163
160
164
To build everything for a given language:
165
+
161
166
```shell
162
167
bazel build //<language>/...
163
168
```
164
169
165
170
To build just the grid there is an alias name to use (the log will show where the output jar is located):
166
-
```sh
171
+
172
+
```shell
167
173
bazel build grid
168
174
```
169
175
170
-
To make things more simple, building each of the bindings is available with this `./go` command
176
+
To make things more simple, building each of the bindings is available with this `./go` command:
177
+
171
178
```shell
172
179
./go <language>:build
173
180
```
174
181
175
-
176
182
## Developing
177
183
178
184
### Java
179
185
180
186
#### IntelliJ
187
+
181
188
Most of the team uses Intellij for their day-to-day editing. If you're
182
189
working in IntelliJ, then we highly recommend installing the [Bazel IJ
183
190
plugin](https://plugins.jetbrains.com/plugin/8609-bazel) which is documented on
@@ -187,13 +194,16 @@ To use Selenium with the IntelliJ Bazel plugin, import the repository as a Bazel
187
194
view file from the [scripts](scripts) directory. `ij.bazelproject` for Mac/Linux and `ij-win.bazelproject` for Windows.
188
195
189
196
#### Linting
197
+
190
198
We also use Google Java Format for linting, so using the Google Java Formatter Plugin is useful;
191
199
there are a few steps to get it working, so read their [configuration documentation](https://github.com/google/google-java-format/blob/master/README.md#intellij-jre-config).
192
200
There is also an auto-formatting script that can be run: `./scripts/format.sh`
193
201
194
202
#### Local Installation
203
+
195
204
While Selenium is not built with Maven, you can build and install the Selenium pieces
196
205
for Maven to use locally by deploying to your local maven repository (`~/.m2/repository`), using:
206
+
197
207
```shell
198
208
./go java:install
199
209
```
@@ -225,18 +235,21 @@ There is also an auto-formatting script that can be run: `./scripts/format.sh`
225
235
#### Local Installation
226
236
227
237
To run Python code locally without building/installing the package, you must first install the dependencies:
238
+
228
239
```shell
229
240
pip install -r py/requirements.txt
230
241
```
231
242
232
243
Then, build the generated files and copy them into your local source tree:
244
+
233
245
```shell
234
246
./go py:local_dev
235
247
```
236
248
237
249
After that, you can import the selenium package directly from source from the `py` directory.
238
250
239
251
Instead of running from source, you can build and install the selenium package (wheel) locally:
252
+
240
253
```shell
241
254
./go py:install
242
255
```
@@ -252,11 +265,12 @@ before installing.
252
265
Instead of using `irb`, you can create an interactive REPL with all gems loaded using: `bazel run //rb:console`
253
266
254
267
If you want to debug code, you can do it via [`debug`](https://github.com/ruby/debug) gem:
268
+
255
269
1. Add `binding.break` to the code where you want the debugger to start.
256
270
2. Run tests with `ruby_debug` configuration: `bazel test --config ruby_debug <test>`.
257
271
3. When debugger starts, run the following in a separate terminal to connect to debugger:
258
272
259
-
```sh
273
+
```shell
260
274
bazel-selenium/external/bundle/bin/rdbg -A
261
275
```
262
276
@@ -270,12 +284,12 @@ you can configure it use Bazel artifacts:
270
284
271
285
### Rust
272
286
273
-
To keep `Carbo.Bazel.lock` synchronized with `Cargo.lock`, run:
287
+
To keep `Cargo.Bazel.lock` synchronized with `Cargo.lock`, run:
288
+
274
289
```shell
275
290
CARGO_BAZEL_REPIN=true bazel sync --only=crates
276
291
```
277
292
278
-
279
293
## Testing
280
294
281
295
There are a number of bazel configurations specific for testing.
@@ -301,12 +315,14 @@ Selenium tests can be filtered by size:
301
315
* medium — tests that are more involved than simple unit tests, but not fully driving a browser
302
316
303
317
These can be filtered using the `test_size_filters` argument like this:
304
-
```sh
318
+
319
+
```shell
305
320
bazel test //<language>/... --test_size_filters=small
306
321
```
307
322
308
323
Tests can also be filtered by tag like:
309
-
```sh
324
+
325
+
```shell
310
326
bazel test //<language>/... --test_tag_filters=this,-not-this
311
327
```
312
328
@@ -319,44 +335,50 @@ so be careful if also using an inherited config
319
335
<summary>Click to see Java Test Commands</summary>
320
336
321
337
To run unit tests:
338
+
322
339
```shell
323
340
bazel test //java/... --test_size_filters=small
324
341
```
325
342
To run integration tests:
343
+
326
344
```shell
327
345
bazel test //java/... --test_size_filters=medium
328
346
```
329
347
To run browser tests:
348
+
330
349
```shell
331
350
bazel test //java/... --test_size_filters=large --test_tag_filters=<browser>
332
351
```
333
352
334
353
To run a specific test:
354
+
335
355
```shell
336
356
bazel test //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest
337
357
```
338
358
339
359
</details>
340
360
341
361
### JavaScript
362
+
342
363
<details>
343
364
<summary>Click to see JavaScript Test Commands</summary>
344
365
345
366
To run the tests run:
346
367
347
-
```sh
368
+
```shell
348
369
bazel test //javascript/selenium-webdriver:all
349
370
```
350
371
351
372
You can use `--test_env` to pass in the browser name as `SELENIUM_BROWSER`.
352
373
353
-
```sh
374
+
```shell
354
375
bazel test //javascript/selenium-webdriver:all --test_env=SELENIUM_BROWSER=firefox
355
376
```
356
377
357
378
</details>
358
379
359
380
### Python
381
+
360
382
<details>
361
383
<summary>Click to see Python Test Commands</summary>
362
384
@@ -367,30 +389,32 @@ bazel test //py:unit
367
389
368
390
To run common tests with a specific browser:
369
391
370
-
```sh
392
+
```shell
371
393
bazel test //py:common-<browsername>
372
394
```
373
395
374
396
To run common tests with a specific browser (include BiDi tests):
375
397
376
-
```sh
398
+
```shell
377
399
bazel test //py:common-<browsername>-bidi
378
400
```
379
401
380
402
To run tests with a specific browser:
381
403
382
-
```sh
404
+
```shell
383
405
bazel test //py:test-<browsername>
384
406
```
385
407
386
408
To run all Python tests:
409
+
387
410
```shell
388
411
bazel test //py:all
389
412
```
390
413
391
414
</details>
392
415
393
416
### Ruby
417
+
394
418
<details>
395
419
<summary>Click to see Ruby Test Commands</summary>
396
420
@@ -452,35 +476,40 @@ Supported environment variables for use with `--test_env`:
452
476
453
477
To run with a specific version of Ruby you can change the version in `rb/.ruby-version` or from command line:
454
478
455
-
```sh
479
+
```shell
456
480
echo'<X.Y.Z>'> rb/.ruby-version
457
481
```
458
482
</details>
459
483
460
484
### .NET
485
+
461
486
<details>
462
487
<summary>Click to see .NET Test Commands</summary>
463
488
464
489
.NET tests currently only work with pinned browsers, so make sure to include that.
465
490
466
491
Run all tests with:
467
-
```sh
492
+
493
+
```shell
468
494
bazel test //dotnet/test/common:AllTests --pin_browsers=true
469
495
```
470
496
471
497
You can run specific tests by specifying the class name:
498
+
472
499
```shell
473
500
bazel test //dotnet/test/common:ElementFindingTest --pin_browsers=true
474
501
```
475
502
476
503
If the module supports multiple browsers:
504
+
477
505
```shell
478
506
bazel test //dotnet/test/common:ElementFindingTest-edge --pin_browsers=true
479
507
```
480
508
481
509
</details>
482
510
483
511
### Rust
512
+
484
513
<details>
485
514
<summary>Click to see Rust Test Commands</summary>
486
515
@@ -502,12 +531,14 @@ alternatively run them in a virtual or nested X-server.
502
531
1. Run the X server `Xvfb :99` or `Xnest :99`
503
532
2. Run a window manager, for example, `DISPLAY=:99 jwm`
504
533
3. Run the tests you are interested in:
505
-
```sh
534
+
535
+
```shell
506
536
bazel test --test_env=DISPLAY=:99 //java/... --test_tag_filters=chrome
507
537
```
508
538
509
539
An easy way to run tests in a virtual X-server is to use Bazel's `--run_under`
510
540
functionality:
541
+
511
542
```
512
543
bazel test --run_under="xvfb-run -a" //java/...
513
544
```
@@ -539,16 +570,19 @@ As discussed in the [Building](#building) section, we use Rake tasks with the `.
539
570
These `./go` commands include the `--stamp` argument to provide necessary information about the constructed asset.
540
571
541
572
You can build and release everything with:
573
+
542
574
```shell
543
575
./go all:release
544
576
```
545
577
546
578
To build and release a specific language:
579
+
547
580
```shell
548
581
./go <language>:release
549
582
```
550
583
551
584
If you have access to the Selenium EngFlow repository, you can have the assets built remotely and downloaded locally using:
0 commit comments