Syntax highlighting for JavasScript examples
Uses the GitHub syntax highlighting for the readme.md
@@ -31,6 +31,7 @@ Safari 10 before testing.
The sample below and others are included in the `example` directory. You may
also find the tests for selenium-webdriver informative.
+```javascript
const {Builder, By, Key, until} = require('selenium-webdriver');
(async function example() {
@@ -43,6 +44,7 @@ also find the tests for selenium-webdriver informative.
await driver.quit();
}
})();
+```
### Using the Builder API
@@ -51,6 +53,7 @@ instances. Rather than clutter your code with branches for the various browsers,
the builder lets you set all options in one flow. When you call
`Builder#build()`, all options irrelevant to the selected browser are dropped:
+```javascript
const webdriver = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const firefox = require('selenium-webdriver/firefox');
@@ -60,6 +63,7 @@ the builder lets you set all options in one flow. When you call
.setChromeOptions(/* ... */)
.setFirefoxOptions(/* ... */)
.build();
+```
Why would you want to configure options irrelevant to the target browser? The
`Builder`'s API defines your _default_ configuration. You can change the target
@@ -92,11 +96,12 @@ server with
You may configure your tests to run against a remote server through the Builder
API:
+```javascript
let driver = new webdriver.Builder()
.forBrowser('firefox')
.usingServer('http://localhost:4444/wd/hub')
.build();
-
+```
Or change the Builder's configuration at runtime with the `SELENIUM_REMOTE_URL`
environment variable:
