aboutsummaryrefslogtreecommitdiff
path: root/node_modules/selenium-webdriver/example
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/selenium-webdriver/example')
-rw-r--r--node_modules/selenium-webdriver/example/chrome_android.js38
-rw-r--r--node_modules/selenium-webdriver/example/chrome_mobile_emulation.js39
-rw-r--r--node_modules/selenium-webdriver/example/google_search.js50
-rw-r--r--node_modules/selenium-webdriver/example/google_search_generator.js45
-rw-r--r--node_modules/selenium-webdriver/example/google_search_test.js47
-rw-r--r--node_modules/selenium-webdriver/example/logging.js43
-rw-r--r--node_modules/selenium-webdriver/example/parallel_flows.js51
7 files changed, 313 insertions, 0 deletions
diff --git a/node_modules/selenium-webdriver/example/chrome_android.js b/node_modules/selenium-webdriver/example/chrome_android.js
new file mode 100644
index 000000000..990a4c445
--- /dev/null
+++ b/node_modules/selenium-webdriver/example/chrome_android.js
@@ -0,0 +1,38 @@
+// Licensed to the Software Freedom Conservancy (SFC) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The SFC licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+/**
+ * @fileoverview A basic example of working with Chrome on Android. Before
+ * running this example, you must start adb and connect a device (or start an
+ * AVD).
+ */
+
+var webdriver = require('..'),
+ By = webdriver.By,
+ until = webdriver.until,
+ chrome = require('../chrome');
+
+var driver = new webdriver.Builder()
+ .forBrowser('chrome')
+ .setChromeOptions(new chrome.Options().androidChrome())
+ .build();
+
+driver.get('http://www.google.com/ncr');
+driver.findElement(By.name('q')).sendKeys('webdriver');
+driver.findElement(By.name('btnG')).click();
+driver.wait(until.titleIs('webdriver - Google Search'), 1000);
+driver.quit();
diff --git a/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js b/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js
new file mode 100644
index 000000000..d3081127d
--- /dev/null
+++ b/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js
@@ -0,0 +1,39 @@
+// Licensed to the Software Freedom Conservancy (SFC) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The SFC licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+/**
+ * @fileoverview This is an example of emulating a mobile device using the
+ * ChromeDriver.
+ */
+
+var webdriver = require('..'),
+ By = webdriver.By,
+ until = webdriver.until,
+ chrome = require('../chrome');
+
+
+var driver = new webdriver.Builder()
+ .forBrowser('chrome')
+ .setChromeOptions(new chrome.Options()
+ .setMobileEmulation({deviceName: 'Google Nexus 5'}))
+ .build();
+
+driver.get('http://www.google.com/ncr');
+driver.findElement(By.name('q')).sendKeys('webdriver');
+driver.findElement(By.name('btnG')).click();
+driver.wait(until.titleIs('webdriver - Google Search'), 1000);
+driver.quit();
diff --git a/node_modules/selenium-webdriver/example/google_search.js b/node_modules/selenium-webdriver/example/google_search.js
new file mode 100644
index 000000000..22d0d21ce
--- /dev/null
+++ b/node_modules/selenium-webdriver/example/google_search.js
@@ -0,0 +1,50 @@
+// Licensed to the Software Freedom Conservancy (SFC) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The SFC licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+/**
+ * @fileoverview An example WebDriver script. This requires the chromedriver
+ * to be present on the system PATH.
+ *
+ * Usage:
+ * // Default behavior
+ * node selenium-webdriver/example/google_search.js
+ *
+ * // Target Chrome locally; the chromedriver must be on your PATH
+ * SELENIUM_BROWSER=chrome node selenium-webdriver/example/google_search.js
+ *
+ * // Use a local copy of the standalone Selenium server
+ * SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \
+ * node selenium-webdriver/example/google_search.js
+ *
+ * // Target a remote Selenium server
+ * SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \
+ * node selenium-webdriver/example/google_search.js
+ */
+
+var webdriver = require('..'),
+ By = webdriver.By,
+ until = webdriver.until;
+
+var driver = new webdriver.Builder()
+ .forBrowser('firefox')
+ .build();
+
+driver.get('http://www.google.com/ncr');
+driver.findElement(By.name('q')).sendKeys('webdriver');
+driver.findElement(By.name('btnG')).click();
+driver.wait(until.titleIs('webdriver - Google Search'), 1000);
+driver.quit(); \ No newline at end of file
diff --git a/node_modules/selenium-webdriver/example/google_search_generator.js b/node_modules/selenium-webdriver/example/google_search_generator.js
new file mode 100644
index 000000000..983c8d84f
--- /dev/null
+++ b/node_modules/selenium-webdriver/example/google_search_generator.js
@@ -0,0 +1,45 @@
+// Licensed to the Software Freedom Conservancy (SFC) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The SFC licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+/**
+ * @fileoverview An example WebDriver script using generator functions.
+ *
+ * Usage: node selenium-webdriver/example/google_search_generator.js
+ */
+
+var webdriver = require('..'),
+ By = webdriver.By;
+
+var driver = new webdriver.Builder()
+ .forBrowser('firefox')
+ .build();
+
+driver.get('http://www.google.com/ncr');
+driver.call(function* () {
+ var query = yield driver.findElement(By.name('q'));
+ query.sendKeys('webdriver');
+
+ var submit = yield driver.findElement(By.name('btnG'));
+ submit.click();
+});
+
+driver.wait(function* () {
+ var title = yield driver.getTitle();
+ return 'webdriver - Google Search' === title;
+}, 1000);
+
+driver.quit();
diff --git a/node_modules/selenium-webdriver/example/google_search_test.js b/node_modules/selenium-webdriver/example/google_search_test.js
new file mode 100644
index 000000000..823e2c578
--- /dev/null
+++ b/node_modules/selenium-webdriver/example/google_search_test.js
@@ -0,0 +1,47 @@
+// Licensed to the Software Freedom Conservancy (SFC) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The SFC licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+/**
+ * @fileoverview An example test that may be run using Mocha.
+ * Usage: mocha -t 10000 selenium-webdriver/example/google_search_test.js
+ */
+
+var webdriver = require('..'),
+ By = webdriver.By,
+ until = webdriver.until,
+ test = require('../testing');
+
+test.describe('Google Search', function() {
+ var driver;
+
+ test.before(function() {
+ driver = new webdriver.Builder()
+ .forBrowser('firefox')
+ .build();
+ });
+
+ test.it('should append query to title', function() {
+ driver.get('http://www.google.com');
+ driver.findElement(By.name('q')).sendKeys('webdriver');
+ driver.findElement(By.name('btnG')).click();
+ driver.wait(until.titleIs('webdriver - Google Search'), 1000);
+ });
+
+ test.after(function() {
+ driver.quit();
+ });
+});
diff --git a/node_modules/selenium-webdriver/example/logging.js b/node_modules/selenium-webdriver/example/logging.js
new file mode 100644
index 000000000..ae1d4cc2a
--- /dev/null
+++ b/node_modules/selenium-webdriver/example/logging.js
@@ -0,0 +1,43 @@
+// Licensed to the Software Freedom Conservancy (SFC) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The SFC licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+/**
+ * @fileoverview Demonstrates how to use WebDriver's logging sysem.
+ */
+
+'use strict';
+
+var webdriver = require('..'),
+ By = webdriver.By,
+ until = webdriver.until;
+
+webdriver.logging.installConsoleHandler();
+webdriver.logging.getLogger('webdriver.http')
+ .setLevel(webdriver.logging.Level.ALL);
+
+var driver = new webdriver.Builder()
+ .forBrowser('firefox')
+ .build();
+
+driver.get('http://www.google.com/ncr');
+
+var searchBox = driver.wait(until.elementLocated(By.name('q')), 3000);
+searchBox.sendKeys('webdriver');
+
+driver.findElement(By.name('btnG')).click();
+driver.wait(until.titleIs('webdriver - Google Search'), 1000);
+driver.quit();
diff --git a/node_modules/selenium-webdriver/example/parallel_flows.js b/node_modules/selenium-webdriver/example/parallel_flows.js
new file mode 100644
index 000000000..f41692234
--- /dev/null
+++ b/node_modules/selenium-webdriver/example/parallel_flows.js
@@ -0,0 +1,51 @@
+// Licensed to the Software Freedom Conservancy (SFC) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The SFC licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+/**
+ * @fileoverview An example of starting multiple WebDriver clients that run
+ * in parallel in separate control flows.
+ */
+
+var webdriver = require('..'),
+ By = webdriver.By,
+ until = webdriver.until;
+
+for (var i = 0; i < 3; i++) {
+ (function(n) {
+ var flow = new webdriver.promise.ControlFlow()
+ .on('uncaughtException', function(e) {
+ console.log('uncaughtException in flow %d: %s', n, e);
+ });
+
+ var driver = new webdriver.Builder().
+ forBrowser('firefox').
+ setControlFlow(flow). // Comment out this line to see the difference.
+ build();
+
+ // Position and resize window so it's easy to see them running together.
+ driver.manage().window().setSize(600, 400);
+ driver.manage().window().setPosition(300 * i, 400 * i);
+
+ driver.get('http://www.google.com');
+ driver.findElement(By.name('q')).sendKeys('webdriver');
+ driver.findElement(By.name('btnG')).click();
+ driver.wait(until.titleIs('webdriver - Google Search'), 1000);
+
+ driver.quit();
+ })(i);
+}
+