Skip to content

Commit

Permalink
[js] Marionette tweaks
Browse files Browse the repository at this point in the history
- Only include a profile in the capabilities if the user actually
provided one. This avoid unnecessarily encoding an empty profile
instance

- Start marionette on a random port so users can drive multiple sessions
at a time
  • Loading branch information
jleyba committed Jun 29, 2016
1 parent 431070e commit d59ccc1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions javascript/node/selenium-webdriver/firefox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,14 @@ function createGeckoDriverService(binary) {

let geckoDriver = findGeckoDriver();
let port = portprober.findFreePort();
let marionettePort = portprober.findFreePort();
return new remote.DriverService(geckoDriver, {
loopback: true,
port: port,
args: Promise.all([exe, port]).then(args => {
return ['-b', args[0], '--webdriver-port', args[1]];
args: Promise.all([exe, port, marionettePort]).then(args => {
return ['-b', args[0],
'--webdriver-port', args[1],
'--marionette-port', args[2]];
})
// ,stdio: 'inherit'
});
Expand Down Expand Up @@ -354,7 +357,7 @@ class Driver extends webdriver.WebDriver {
binary = new Binary(binary);
}

let profile = new Profile();
let profile;
if (caps.has(Capability.PROFILE)) {
profile = caps.get(Capability.PROFILE);
caps.delete(Capability.PROFILE);
Expand All @@ -373,9 +376,14 @@ class Driver extends webdriver.WebDriver {
let service = createGeckoDriverService(binary);
serverUrl = service.start();
onQuit = () => service.kill();
caps.set(Capability.PROFILE, profile.encode());

if (profile) {
caps.set(Capability.PROFILE, profile.encode());
}

} else {
profile = profile || new Profile;

let freePort = portprober.findFreePort();
let preparedProfile =
freePort.then(port => prepareProfile(profile, port));
Expand Down

0 comments on commit d59ccc1

Please sign in to comment.