Skip to content

Commit

Permalink
Native support for Firefox in the JS bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed Aug 23, 2014
1 parent 152aec2 commit 6a24b8b
Show file tree
Hide file tree
Showing 24 changed files with 1,838 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ common/build
cpp/iedriver/IEReturnTypes.h
java/client/src/org/openqa/selenium/ie/IeReturnTypes.java
javascript/deps.js
javascript/node/selenium-webdriver/node_modules/
.idea/vcs.xml
.idea/misc.xml
.idea/workspace.xml
Expand Down
33 changes: 33 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,39 @@ namespace :docs do
end
end

namespace :node do
task :deploy => [
"//javascript/firefox-driver:webdriver",
"//javascript/webdriver:asserts_lib",
"//javascript/webdriver:webdriver_lib",
"//javascript/webdriver:unit_test_lib"
] do
js = Javascript::BaseJs.new
# Get JS lib deps, excluding those need to build the FirefoxDriver.
deps = js.build_deps("", Rake::Task["//javascript/webdriver:asserts_lib"], [])
deps = js.build_deps("", Rake::Task["//javascript/webdriver:webdriver_lib"], deps)
deps = js.build_deps("", Rake::Task["//javascript/webdriver:unit_test_lib"], deps)
deps.uniq!

cmd = "node javascript/node/deploy.js" <<
" --output=build/javascript/node/selenium-webdriver" <<
" --resource=COPYING:/COPYING" <<
" --resource=javascript/firefox-driver/webdriver.json:firefox/webdriver.json" <<
" --resource=build/javascript/firefox-driver/webdriver.xpi:firefox/webdriver.xpi" <<
" --resource=third_party/closure/LICENSE:goog/LICENSE" <<
" --resource=common/src/web/:test/data/" <<
" --exclude_resource=common/src/web/Bin" <<
" --exclude_resource=.gitignore" <<
" --root=javascript" <<
" --root=third_party/closure" <<
" --lib=third_party/closure/goog" <<
" --lib=" << deps.join(" --lib=") <<
" --src=javascript/node/selenium-webdriver"

sh cmd
end
end

namespace :safari do
desc "Build the SafariDriver extension"
task :extension => [ "//javascript/safari-driver:SafariDriver" ]
Expand Down
24 changes: 3 additions & 21 deletions javascript/node/build.desc
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
node_module(
name = "selenium-webdriver",
srcdir = "selenium-webdriver",
deps = [
"//javascript/webdriver:asserts_lib",
"//javascript/webdriver:webdriver_lib",
"//javascript/webdriver:unit_test_lib",
],
content_roots = [
"javascript",
"third_party/closure"
],
resources = [
{ "COPYING" : "/COPYING" },
{ "third_party/closure/LICENSE" : "goog/LICENSE" },
{ "common/src/web/" : "test/data/" },
],
exclude_resources = [
"common/src/web/Bin",
"\.gitignore",
])
rake_task(name = "selenium-webdriver",
task_name = "node:deploy",
out = "javascript/node/selenium-webdriver")
9 changes: 8 additions & 1 deletion javascript/node/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ function processLibraryFiles(filePaths, contentRoots) {
function copySrcs(srcDir, outputDirPath) {
var filePaths = fs.readdirSync(srcDir);
filePaths.forEach(function(filePath) {
if (filePath === 'node_modules') {
return;
}
filePath = path.join(srcDir, filePath);
if (fs.statSync(filePath).isDirectory()) {
copySrcs(filePath, path.join(outputDirPath, path.basename(filePath)));
Expand Down Expand Up @@ -377,7 +380,11 @@ function generateDocs(outputDir, callback) {
'readme': path.join(outputDir, 'README.md'),
'language': 'ES5',
'sources': sourceFiles,
'modules': moduleFiles
'modules': moduleFiles,
'excludes': [
path.join(outputDir, 'docs'),
path.join(outputDir, 'node_modules')
]
};

var configFile = outputDir + '-docs.json';
Expand Down
2 changes: 2 additions & 0 deletions javascript/node/selenium-webdriver/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/

2 changes: 2 additions & 0 deletions javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## v2.43.0-dev

* Added native support for Firefox - the Java Selenium server is no longer
required.
* Added support for generator functions to `ControlFlow#execute` and
`ControlFlow#wait`. For more information, see documentation on
`webdriver.promise.consume`. Requires harmony support (run with
Expand Down
28 changes: 28 additions & 0 deletions javascript/node/selenium-webdriver/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ var Builder = function() {

/** @private {chrome.Options} */
this.chromeOptions_ = null;

/** @private {firefox.Options} */
this.firefoxOptions_ = null;
};


Expand Down Expand Up @@ -218,6 +221,21 @@ Builder.prototype.setChromeOptions = function(options) {
};


/**
* Sets Firefox-specific options for drivers created by this builder. Any
* logging or proxy settings defined on the given options will take precedence
* over those set through {@link #setLoggingPrefs} and {@link #setProxy},
* respectively.
*
* @param {!firefox.Options} options The FirefoxDriver options to use.
* @return {!Builder} A self reference.
*/
Builder.prototype.setFirefoxOptions = function(options) {
this.firefoxOptions_ = options;
return this;
};


/**
* Sets the control flow that created drivers should execute actions in. If
* the flow is never set, or is set to {@code null}, it will use the active
Expand Down Expand Up @@ -264,6 +282,10 @@ Builder.prototype.build = function() {
capabilities.merge(this.chromeOptions_.toCapabilities());
}

if (browser === Browser.FIREFOX && this.firefoxOptions_) {
capabilities.merge(this.firefoxOptions_.toCapabilities());
}

// Check for a remote browser.
var url = process.env.SELENIUM_REMOTE_URL || this.url_;
if (url) {
Expand All @@ -279,6 +301,12 @@ Builder.prototype.build = function() {
var chrome = require('./chrome');
return new chrome.Driver(capabilities, null, this.flow_);

case Browser.FIREFOX:
// Requiring 'firefox' above would create a cycle:
// index -> builder -> firefox -> index
var firefox = require('./firefox');
return new firefox.Driver(capabilities, this.flow_);

case Browser.PHANTOM_JS:
// Requiring 'phantomjs' would create a cycle:
// index -> builder -> phantomjs -> index
Expand Down
Loading

0 comments on commit 6a24b8b

Please sign in to comment.