Skip to content

Commit

Permalink
[JS] Set browserName by default when browserOptions are used
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha509 committed Apr 4, 2024
1 parent aaa7e79 commit b49ae75
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions javascript/node/selenium-webdriver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,17 @@ class Builder {

browser = capabilities.get(Capability.BROWSER_NAME)

/**
* If browser is not defined in forBrowser, check if browserOptions are defined to pick the browserName
*/
if (!browser) {
const options =
this.chromeOptions_ || this.firefoxOptions_ || this.ieOptions_ || this.safariOptions_ || this.edgeOptions_
if (options) {
browser = options['map_'].get(Capability.BROWSER_NAME)
}
}

if (typeof browser !== 'string') {
throw TypeError(
`Target browser must be a string, but is <${typeof browser}>;` + ' did you forget to call forBrowser()?',
Expand Down

0 comments on commit b49ae75

Please sign in to comment.