angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

protractor should be able to find webdriver-manager installed chromedriver all by its merry little self, no? #5397

Open josh-m-sharpe opened 4 years ago

josh-m-sharpe commented 4 years ago

If you google something like Error message: Could not find chromedriver at you get about eight million three hundred and seventy five billion results. Someone, somewhere, is doing something wrong and with that many questions/explanations/solutions, it's mostly likely not the end-user-developers.

The rest of that error message says something like Run 'webdriver-manager update' to download binaries. Right on, okay, but I just ran that.

My test script looks something like this:

npx webdriver-manager update
npm run e2e

Yet, it still blows up with this error message.

It seems to me that if I do the thing that the error message tells me to do, and it still fails, then there's a problem with the library. At a minimum the instructions to run webdriver-manager update are inaccurate.

Is anyone else tired of this error message popping up every time google updates chrome, or chromedriver, or whatever else it is that makes this thing rear its ugly head every 2.8 months?

webdriver-manager seems to be doing the correct things. It downloads, unzips and sticks various binaries in a normalized place inside node_modules. Why can't protractor find them? It seems to me that if protractor is using webdriver-manager, then protractor ought to be smart enough to find the binaries that webdriver-manager is managing. Further, that would seem to make config options like chromeDriver (and similar) less important and/or unnecessary.

If that's not an option, could we update the error message to be more accurate? Maybe it could point to a wiki page with suggestions for various fixes.

One way or another, simply running webdriver-manager update is not the solution.

praveendvd commented 4 years ago

hi just mention your chromedriver location in configfile directly as :

eg: chromeDriver: "c:/chromedriver.exe",

exports.config = {
specs: ['test.js'],
chromeDriver: "<path>",  
capabilities: {
  'browserName': 'chrome' // or 'safari'
},

onPrepare: function(){
    browser.waitForAngularEnabled(false);
    browser.driver.manage().window().maximize();
},

  jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report.
    defaultTimeoutInterval: 5000000,

},
SELENIUM_PROMISE_MANAGER: false,
}
praveendvd commented 4 years ago

See the config.ts to know more about all the allowed options:

https://github.com/angular/protractor/blob/5.4.1/lib/config.ts

About the issue you are facing , make sure that you are using webdriver-manager installed along with protractor and not a separate installation:

To check this, open command prompt and then run below command.

where webdriver-manager

Now open, webdriver-manager.cmd in notepad (run below command to do that

notepad <path>/webdriver-anager.cmd

Now check that you can see the below line in the file:

"%_prog%" "%dp0%\node_modules\protractor\bin\webdriver-manager" %*

make sure the webdriver-manager is under the protractor installation.

Now when you run webdriver-manager update ensure that the binaries are getting downloaded to

\npm\node_modules\protractor\node_modules\webdriver-manager\selenium

npm\node_modules\protractor\node_modules\webdriver-manager\selenium\

josh-m-sharpe commented 4 years ago

@praveendvd last I checked the path to chrome driver changes with every version... which is the whole point here. The path isn’t configurable.

Ironic you commented at this moment since i have a build failing at this very moment... again... because of this very issue.

praveendvd commented 4 years ago

@josh-m-sharpe 'chromeDriver' property is to set path for the binary. COuld you try that and also do the check i mentioned in the second comment?

if chromeDriver is specified, then protractor will check for chromedriver in that location only, else it will look for in default location which is protractor\node_modules\webdriver-manager\selenium

josh-m-sharpe commented 4 years ago

@praveendvd a few things:

1) I have previously been using npx webdriver-manager to use webdriver-manager, but since you asked nicely, I used the one bundled with protractor. It does not install the chromedriver binaries inside node_modules/protractor as you seem to think it does. It installs them in node_modules/webdriver-manager/.... See here:

$ node_modules/protractor/node_modules/webdriver-manager/bin/webdriver-manager update
webdriver-manager: using local installed version 12.1.7
[12:09:46] I/update - selenium standalone: file exists /Users/jsharpe/project/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar
[12:09:46] I/update - selenium standalone: selenium-server-standalone-3.141.59.jar up to date
[12:09:48] I/update - chromedriver: file exists /Users/jsharpe/project/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.106.zip
[12:09:48] I/update - chromedriver: unzipping chromedriver_80.0.3987.106.zip
[12:09:48] I/update - chromedriver: setting permissions to 0755 for /Users/jsharpe/project/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.106
[12:09:48] I/update - chromedriver: chromedriver_80.0.3987.106 up to date
[12:09:49] I/update - geckodriver: file exists /Users/jsharpe/project/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0.tar.gz
[12:09:49] I/update - geckodriver: unzipping geckodriver-v0.26.0.tar.gz
[12:09:49] I/update - geckodriver: setting permissions to 0755 for /Users/jsharpe/project/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0
[12:09:49] I/update - geckodriver: geckodriver-v0.26.0 up to date

2) Further, it still installs them in a path with a version number. This is BAD as it means that I have to configure the path with that version and every time chromedriver is updated, I have to go update that version. This is the whole point.

3) I wasn't aware protractor bundled its own version of webdriver. It's interesting that it does that, but then doesn't actually use webdriver-manager to install the binaries automatically. The whole chromeDriver config option shouldn't even be necessary because protractor should be able to install the binaries, configure their location, and ensure they are ready to go all by its little self. It seems to me that users of protractor shouldn't have to be bothered with configuring/managing any of that.

praveendvd commented 4 years ago

jus run the protractor specific webdriver which is at:

protractor\node_modules\.bin

The command is

"<path>\node_modules\protractor\node_modules\.bin\webdriver-manager" update

else you specify the output folder using the --out_dir flag

webdriver-manager update --out_dir "<path>\protractor\node_modules\webdriver-manager\selenium"

\noe you don't have to give chromeDIrver property in config file, protractor will automatically identify the drivers from \protractor\node_modules\webdriver-manager\selenium

josh-m-sharpe commented 4 years ago

I did that. See my last comment.

Besides that, you are missing my point.

If protractor depends on webdriver-manager, and webdriver-manager installs binaries for us, then then I should. not. have. to. configure. the locations. of. the. binaries. If you don't see that, or don't understand it, please stop responding. I am not looking for instruction on how to use webdriver-manager and configure protractor accordingly. I know how to do that, but I shouldn't have to.

awarecan commented 4 years ago

You should only have protractor in your package.json. Do not put webdriver-manager in dependencies. Do not install webdriver-manager globally.

josh-m-sharpe commented 4 years ago

@awarecan This issue happens when webdriver-manager is not in the package.json

Regardless if it is or not, protractor has its own copy and doesn't know how to use it.

wilwer commented 4 years ago

Is something happening regarding this? because i'm hit too and whatever i do, protractor seems to fail to recognise the setting for the preinstalled (using protractors webdriver-manager) chrome driver chromeDriver: "C:/s/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.106.exe", and fanatically downloads a newer (unsuitable) driver in .\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_81.0.4044.69.zip

praveendvd commented 4 years ago

Is something happening regarding this? because i'm hit too and whatever i do, protractor seems to fail to recognise the setting for the preinstalled (using protractors webdriver-manager) chrome driver chromeDriver: "C:/s/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.106.exe", and fanatically downloads a newer (unsuitable) driver in .\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_81.0.4044.69.zip

Thats the expected behaviour of webdriver-manager , latest chrome is 81 . you have to update chrome or use

webdriver-manager update --versions.chrome 80.0.3987.106

mark-at-tusksoft commented 4 years ago

Is something happening regarding this? because i'm hit too and whatever i do, protractor seems to fail to recognise the setting for the preinstalled (using protractors webdriver-manager) chrome driver chromeDriver: "C:/s/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.106.exe", and fanatically downloads a newer (unsuitable) driver in .\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_81.0.4044.69.zip

Thats the expected behaviour of webdriver-manager , latest chrome is 81 . you have to update chrome or use

webdriver-manager update --versions.chrome 80.0.3987.106

Tried this, I see node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.106.exe present in the folder but I am still getting Error: SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 81

I have tried reinstalling protractor and made sure webdriver-manager is not installed either. My local version of Chrome is up-to-date @ v81.0.4044.92 Also I am using puppeteer which appears to be on Chrome v80.0.3987.0 Using the older webdriver should have fixed that if that was problem, right?

josh-m-sharpe commented 4 years ago

To explicitly answer @wilwer's question: No, nothing has been done about this issue. Protractor still cannot determine which version of chrome it just installed.

praveendvd commented 4 years ago

Is something happening regarding this? because i'm hit too and whatever i do, protractor seems to fail to recognise the setting for the preinstalled (using protractors webdriver-manager) chrome driver chromeDriver: "C:/s/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.106.exe", and fanatically downloads a newer (unsuitable) driver in .\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_81.0.4044.69.zip

Thats the expected behaviour of webdriver-manager , latest chrome is 81 . you have to update chrome or use webdriver-manager update --versions.chrome 80.0.3987.106

Tried this, I see node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.106.exe present in the folder but I am still getting Error: SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 81

I have tried reinstalling protractor and made sure webdriver-manager is not installed either. My local version of Chrome is up-to-date @ v81.0.4044.92 Also I am using puppeteer which appears to be on Chrome v80.0.3987.0 Using the older webdriver should have fixed that if that was problem, right?

If you already had local webdriver installed , then rebuild the local project and reinstall protractor after uninstalling webdriver, that worked for me

mark-at-tusksoft commented 4 years ago

Found the issue for my setup. I was following a guide for setting up my app with Azure Pipelines. When puppeteer was setup, protractor.conf.js also needs the binary for puppeteer's install of Chrome process.env.CHROME_BIN = process.env.CHROME_BIN || require("puppeteer").executablePath(); This means the webdriver also needs to be explicitly defined as well inside the protractor conf chromeDriver: "./node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_80.0.3987.0.exe"

On top of the above this also involves using the package.json script for fetching the expected driver "webdriver-update": "node ./node_modules/protractor/bin/webdriver-manager update --versions.chrome=80.0.3987.0"

It's a bit of a hacky solution and there is probably a way to get puppeteer's chrome version in protractor.conf.js using something along the lines of process.env.CHROME_BIN --version; however, it appears to be working now. Hope this helps someone.