-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add promise support for generator functions.
Requires using harmony (node v0.11.x)
- Loading branch information
Showing
10 changed files
with
625 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
javascript/node/selenium-webdriver/example/google_search_generator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2013 Selenium committers | ||
// Copyright 2013 Software Freedom Conservancy | ||
// | ||
// Licensed 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 Harmony generator functions. | ||
* This requires node v0.11 or newer. | ||
* | ||
* Usage: node --harmony-generators \ | ||
* selenium-webdriver/example/google_search_generator.js | ||
*/ | ||
|
||
var webdriver = require('..'); | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
|
||
driver.get('http://www.google.com'); | ||
driver.call(function* () { | ||
var query = yield driver.findElement(webdriver.By.name('q')); | ||
query.sendKeys('webdriver'); | ||
|
||
var submit = yield driver.findElement(webdriver.By.name('btnG')); | ||
submit.click(); | ||
}); | ||
|
||
driver.wait(function* () { | ||
var title = yield driver.getTitle(); | ||
return 'webdriver - Google Search' === title; | ||
}, 1000); | ||
|
||
driver.quit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<script src="test_bootstrap.js"></script> | ||
<script> | ||
goog.require('goog.testing.jsunit'); | ||
</script> | ||
<script> | ||
function shouldRunTests() { | ||
try { | ||
new Function('function* x() {}'); | ||
return true; | ||
} catch (ex) { | ||
return false; | ||
} | ||
} | ||
|
||
// Don't even load the test file if the current browser does not support | ||
// generators as the file will fail to parse. In these cases, we need to | ||
// manually bootstrap Closure's JSUnit framework to make sure the WebDriver | ||
// runner is able to collect results. | ||
if (!shouldRunTests()) { | ||
G_testRunner.setStrict(false); | ||
} else { | ||
goog.require('webdriver.test.promise.generator.test'); | ||
} | ||
</script> | ||
<body></body> |
Oops, something went wrong.