Skip to content

Commit

Permalink
Log browser name in steps #51
Browse files Browse the repository at this point in the history
  • Loading branch information
schipiga committed Nov 1, 2018
1 parent 45ee76a commit 671f3b6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/steps/browser.js
Expand Up @@ -242,7 +242,7 @@ var BrowserSteps = {
opts.tryExisting = U.defVal(opts.tryExisting, false);
this.webUrl = U.defVal(this.webUrl, CONF.web.url);

let name;
let name, isNewBrowser = false;
if (!opts.tryExisting || !this.webdriver) {
const webdriverConf = U.defVal(opts.webdriver, CONF.webdriver);

Expand All @@ -252,15 +252,17 @@ var BrowserSteps = {
`Browser name "${name}" is used already. Choose another.`).to.not.exist;

this.webdriver = this.__wdio.remote(webdriverConf);
isNewBrowser = true;
} else {
name = this._webdrivers().getKey(this.webdriver);
if (await this.webdriver.session()) {
LOG.debug("Browser is launched already");
LOG.debug(`Browser "${name}" is launched already`);
return false;
}
}

allure.step("Launch browser via selenium");
LOG.info("Launching browser via selenium...");
allure.step(`Launch browser "${name}" via selenium`);
LOG.info(`Launching browser "${name}" via selenium...`);

if (CONF.web.platform === "pc" &&
this.webdriver.desiredCapabilities.browserName === "chrome") {
Expand All @@ -283,7 +285,7 @@ var BrowserSteps = {

allure.pass();

if (name) this._webdrivers().push(this.webdriver, name);
if (isNewBrowser) this._webdrivers().push(this.webdriver, name);
return true;
},

Expand Down Expand Up @@ -413,6 +415,7 @@ var BrowserSteps = {
opts.switchPrev = U.defVal(opts.switchPrev, true);
opts.check = U.defVal(opts.check, true);

const name = this._webdrivers().getKey(this.webdriver);
const webdriver = this.webdriver;

if (opts.switchPrev) {
Expand All @@ -421,8 +424,8 @@ var BrowserSteps = {
this.webdriver = this._webdrivers().top();
}

allure.step("Close browser");
LOG.info("Closing browser...");
allure.step(`Close browser "${name}"`);
LOG.info(`Closing browser "${name}"...`);

await webdriver.end();
await this.pause(1, "webdriver process will be stopped");
Expand Down

0 comments on commit 671f3b6

Please sign in to comment.