angular / protractor

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

Work-around to use Protractor@5.4.2 with Chrome 74+ #5225

Open luker2 opened 5 years ago

luker2 commented 5 years ago

@cnishina Does a work-around exist? Or maybe the possibility of a minor protractor 5 release with latest webdriver fixes/updates?

Reason: It's a huge effort to migrate large protractor projects to version 6.0.0. When chrome auto-updates, you are SOL.

Explanation of problem Protractor Error

cnishina commented 5 years ago

There is a fix that is currently tied to webdriver-manager 13.

Good news is that when these changes were happening, I was working on fixing webdriver-manager. You could use Protractor 5.4.2 with webdriver-manager 13. https://github.com/angular/webdriver-manager/pull/372 however I'm not sure how this works with direct connect and local if there are more than one version of webdriver-manager in the node modules directory.

Could we release webdriver-manager 13 with Protractor 5? Possibly but it might be considered as a breaking change since I removed mobile support for webdriver-manager in version 13.

cnishina commented 5 years ago

Setting discussion tag for Protractor 5 + webdriver-manager 13 release.

luker2 commented 5 years ago

I'm actually surprised this hasn't stirred up more conversation. I could be wrong, but I'd think other companies on 5.4.2 would be hit by this and also feel the urgency to find a work-around instead of upgrade to 6.0.0.

Can anyone guess the effort needed to create another 5.x.x release?

@cnishina Before your reply I tried hacking around to get the latest webdriver-manager to work with 5.4.2 with no luck. I simply:

  1. npm installed 13
  2. ran webdriver-manager update to download chromedriver 74
  3. copied the selenium folder
    • from node_modules\webdriver-manager\selenium
    • to node_modules\protractor\node_modules\webdriver-manager\selenium
cnishina commented 5 years ago

Yup. I was looking at the master branch when looking at the driver providers and not 5.4.2. So there's more work to be done to get 13 to work. Let me go update my PR. I might have to create a beta release for webdriver-manager to experiment with this.

cnishina commented 5 years ago

Okay https://github.com/angular/webdriver-manager/pull/372 is my workaround for 13 with Protractor 5.4.2 (with tests!).

luker2 commented 5 years ago

Well I'm at a loss now. All the sudden today I no longer receive yesterday's error, and tests run fine on chrome 74 & chromedriver 2.46

So before, tests were running fine on 73, I purposely updated to 74, then received the above error. So I just assumed it was related, and that anyone who upgraded chrome to 74 would no longer be able to run tests unless they spun up a selenium grid hub/node locally.

According to docs, Chromedriver 2.46 doesn't support chrome 74, but it at least allows me to run tests now? Any idea what else could've changed? Or if that error was even related?

Chrome 74.0.3729.108 Protractor 5.4.2 webdriver-manager 12.1.2 chromedriver_2.46

luker2 commented 5 years ago

Nevermind, I just saw your SO post and, looking at our previous build logs, it looks like webdriver:manager update was downloading

selenium-server-standalone-4.0.0-alpha-1.zip.jar instead of selenium-server-standalone-3.141.59.jar

cnishina commented 5 years ago

So now this is an actual issue. Chrome 74 came out and Protractor 5.4.2 uses webdriver-manager 12.x.x. This only downloads 2.xx chromedrivers. This is a problem and we'll have a hot fix out for this soon.

cnishina commented 5 years ago

Related https://github.com/angular/webdriver-manager/issues/376

cnishina commented 5 years ago

So here's the fix for webdriver-manager 12 which will work with Protractor 5.4.2: https://github.com/angular/webdriver-manager/pull/377

cnishina commented 5 years ago

So this has now been resolved with the release of webdriver-manager@12.1.3.

How to get it?

cnishina commented 5 years ago

More information here on StackOverflow post: https://stackoverflow.com/questions/55910242/when-using-protractor-5-4-2-webdriver-manager-downloads-2-46-which-is-not-compa/55911176#55911176

Kurt29 commented 5 years ago

I have the problem that Protractor still installs driver 2.46 and when I try to install webdriver-manager on my own and add it to my dependencies, the installed chromedriver cannot be found by Protractor

"C:\Program` Files\nodejs\node.exe" C:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\bin\protractor "C:\Users\Kurt\WebStorm 2019.1.1\plugins\JavaScriptLanguage\helpers\protractor-intellij\lib\protractor-intellij-config.js" --intellijOriginalConfigFile=C:\Users\Kurt\WebstormProjects\hcp\e2e\protractor.conf.js --disableChecks --specs C:\Users\Kurt\WebstormProjects\hcp\e2e\src\settings\homepage.e2e-spec.ts "--grep=^core "
[02:18:10] I/launcher - Running 1 instances of WebDriver
[02:18:10] I/direct - Using ChromeDriver directly...
[02:18:10] E/direct - Error code: 135
[02:18:10] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[02:18:10] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
    at Direct.getNewDriver (C:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\built\driverProviders\direct.js:63:31)
    at Runner.createBrowser (C:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\built\runner.js:195:43)
    at C:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\built\runner.js:339:29
    at _fulfilled (C:\Users\Kurt\WebstormProjects\hcp\node_modules\q\q.js:834:54)
    at C:\Users\Kurt\WebstormProjects\hcp\node_modules\q\q.js:863:30
    at Promise.promise.promiseDispatch (C:\Users\Kurt\WebstormProjects\hcp\node_modules\q\q.js:796:13)
    at C:\Users\Kurt\WebstormProjects\hcp\node_modules\q\q.js:556:49
    at runSingle (C:\Users\Kurt\WebstormProjects\hcp\node_modules\q\q.js:137:13)
    at flush (C:\Users\Kurt\WebstormProjects\hcp\node_modules\q\q.js:125:13)
    at processTicksAndRejections (internal/process/task_queues.js:81:9)
[02:18:10] E/launcher - Process exited with error code 135

Process finished with exit code 135

And here is the config file

const {SpecReporter} = require('jasmine-spec-reporter');

exports.config = {
  SELENIUM_PROMISE_MANAGER: false,
  allScriptsTimeout: 11000,
  specs: [
    './src/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    random: true,
    showColors: true,
    defaultTimeoutInterval: 30000
  },
  random: false,
  onPrepare: async () => {
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.e2e.json')
    });
    jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
    await browser.driver.manage().window().maximize();
  }
};

When I run webdriver-manager update

webdriver-manager: using local installed version 12.1.3
[02:33:40] I/update - chromedriver: file exists C:\Users\Kurt\WebstormProjects\hcp\node_modules\webdriver-manager\selenium\chromedriver_75.0.3770.8.zip
[02:33:40] I/update - chromedriver: unzipping chromedriver_75.0.3770.8.zip
[02:33:40] I/update - chromedriver: chromedriver_75.0.3770.8.exe up to date
[02:33:41] I/update - selenium standalone: file exists C:\Users\Kurt\WebstormProjects\hcp\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.141.59.jar
[02:33:41] I/update - selenium standalone: selenium-server-standalone-3.141.59.jar up to date
[02:33:41] I/update - geckodriver: file exists C:\Users\Kurt\WebstormProjects\hcp\node_modules\webdriver-manager\selenium\geckodriver-v0.24.0.zip
[02:33:41] I/update - geckodriver: unzipping geckodriver-v0.24.0.zip
[02:33:41] I/update - geckodriver: geckodriver-v0.24.0.exe up to date
Kurt29 commented 5 years ago

When I remove webdriver-manager from package.json, delete node_modules and run npm i , npm i-f and webdriver-manager update I get

C:\Users\Kurt\WebstormProjects\hcp>webdriver-manager update
[02:38:17] I/file_manager - creating folder C:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\node_modules\webdriver-manager\selenium
[02:38:17] I/config_source - curl -oC:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\node_modules\webdriver-manager\selenium\standalone-response.xml https://selenium-release.storage.googleapis.com/
[02:38:17] I/config_source - curl -oC:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\node_modules\webdriver-manager\selenium\chrome-response.xml https://chromedriver.storage.googleapis.com/
[02:38:17] I/config_source - curl -oC:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\node_modules\webdriver-manager\selenium\gecko-response.json https://api.github.com/repos/mozilla/geckodriver/releases
[02:38:17] I/downloader - curl -oC:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\node_modules\webdriver-manager\selenium/chromedriver_2.46.zip https://chromedriver.storage.googleapis.com/2.46/chromedriver_win32.zip
[02:38:18] I/downloader - curl -oC:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\node_modules\webdriver-manager\selenium/selenium-server-standalone-3.141.59.jar https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
[02:38:18] I/update - chromedriver: unzipping chromedriver_2.46.zip
[02:38:19] I/downloader - curl -oC:\Users\Kurt\WebstormProjects\hcp\node_modules\protractor\node_modules\webdriver-manager\selenium/geckodriver-v0.24.0.zip https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-win64.zip
[02:38:20] I/update - geckodriver: unzipping geckodriver-v0.24.0.zip

C:\Users\Kurt\WebstormProjects\hcp>
cnishina commented 5 years ago

@Kurt29 Weird, you could check the version with node_modules/protractor/node_modules/webdriver-manager/package.json. Are you using global installs?

cnishina commented 5 years ago

Proposed fixes for downloading specific versions, starting specific versions, status, and preventing 75 from being downloaded.

https://github.com/angular/webdriver-manager/issues/376

cnishina commented 5 years ago

I just released 12.1.4 with fix: https://github.com/angular/webdriver-manager/pull/380. This should fix the issues we are seeing with chromedriver 75 and chrome 74 mismatches. Also you should be able to download --versions.chrome 74.0.3729.6 with 12.1.4. This was broken in 12.1.3.

@luker2 Would you like to verify this with me and try out 12.1.4?

cnishina commented 5 years ago

Okay this has been verified in https://github.com/angular/webdriver-manager/issues/376

luker2 commented 5 years ago

@cnishina Works on my end.

I specified both 74 and 75 using the --versions.chrome flag and it downloaded the respective drivers. Without the flag it downloaded 74.0.3729.6

Thanks!

cnishina commented 5 years ago

Here is the StackOverflow post that goes along with this: https://stackoverflow.com/questions/55910242/when-using-protractor-5-4-2-webdriver-manager-downloads-2-46-which-is-not-compa

niyarlatotep commented 5 years ago

I reinstalled protractor in my local node_modules but webdriver-manager version remaind the same: "webdriver-manager": "^12.0.6". Also tried to install locally in new folder, same result. Possibly it's an npm issue ...

niyarlatotep commented 5 years ago

Noticed that in webdriver-manager package.json webdriver-manager is correct "version": "12.1.4" but in protractor package.json dependencies webdriver-manager version is "webdriver-manager": "^12.0.6". It confused me. However everithing works well.

cnishina commented 5 years ago

Yes, ^12.0.6 means to grab the latest minor version release. So in this case, 12.1.4 is the one it will download.

shihuawang commented 5 years ago

Even though it looks like successfully installed, but all of my Protractor test cases failed. It worked on Friday (3 days ago) but failed again now. The failure started when google-chrome-stable upgraded to 74.0.3729.131-1. I initially was able to get my test work by installing the previous google-chrome-stable version. And Friday worked with Protractor 5-4-2 and Chrome 74. But now it doesn't work again, and can't find any work around. Please advise.

shihuawang commented 5 years ago

I'm on ubuntu 16.04 docker.

niyarlatotep commented 5 years ago

@cnishina sure I completely forgot about "^" npm versions thank you for explanation and fix

shihuawang commented 5 years ago

Since #5230 is closed, I move comments here:

Because the new version of webdriver-manager@12.1.4 doesn't work (it worked only on May 3, Friday ), I had to try old version, but it doesn't work either.

Chrome 73 worked before May 3, Friday, but no longer work after that. We can't run our test now. We need a solution. Please advice. Thanks in advance.

shihuawang commented 5 years ago

Clarification: The old version I installed before works fine. But when I create docker, now, with either the current version or old version does not work. So looks like something in some new version is broken.

shihuawang commented 5 years ago

I have narrowed down the issue. The failure is encountered when the Angular code define a button as: <button type="submit" class="btn btn-info pull-right" ui-sref="xxx.xxx.xxx">Create New Element</button> and the Protractor test script is: browser.driver.findElements(by.xpath('//*[contains(text(), "' + arguments[0] + '")]')); where arguments[0] = "Create New Element"

raymonsaadalla commented 5 years ago

Currently i have the webdriver manager version 12.1.4, and chromedriver 74.0.3729.6 so everything should work, but my tests are failing when run on chrome browser 74.0.3729.131; however, it works perfectly fine if I run it on previous 73 version. any suggestion? Thanks

shihuawang commented 5 years ago

It doesn't seem to related to the application Web UI code and test script, and my work-around failed again. It looks like that the new version cannot handle benign exceptions or non-blocking error returns. So I don't really have a work around unless completely change the application code so that it doesn't return error or throw exceptions.

shihuawang commented 5 years ago

Only the system installed when the 73 was released works. But if you install 73 to new server it doesn't work either.

shihuawang commented 5 years ago

Is there a way I can get any version (new install) work?

shihuawang commented 5 years ago

Something happened Friday, it was working Friday.

Priyankajoshipj commented 5 years ago

Hi @cnishina ,

We have the similar problem as @shihuawang and @raymonsaadalla . Our company has a whole Code base of Automated scripts that we run on Protractor, and now that Chrome automatically updated to version 74, the test cases are not getting executed.

We have the following versions of applications:

We also did a fresh install of webdriver-manager and Protractor (the same versions as above). Running Protractor scripts got the same result, the Chrome browser appears but then hangs forever.

Unfortunately, downgrading Chrome to version 73 is not an option for us. Is there a workaround to get past this issue?

ghost commented 5 years ago

I am in the same company with @Priyankajoshipj. (All my applications are the same versions as hers listed above.) The attached image of our Google Chrome browser is what happens when we try to run a Protractor script. The browser appears then hangs like that forever. The test times out, and the browser still stays like that until we manually close it.

2019-05-10_Hanging Protractor

cnishina commented 5 years ago

@Niyarlatotep I noticed that the npm associated with node version 10.9.0 downloaded webdriver-manager version 12.0.6. When I tried node version 10.15.3, Protractor 5.4.2 includes webdriver-manager 12.1.4. If you still have this issue, I would look into any known issues with npm.

@shihuawang I made an example test. We have pretty similar chrome + chromedriver versions. https://github.com/cnishina/protractor542-chrome74 In this example, I have included the Chrome version and ChromeDriver versions that was downloaded. This works for me at least for a simple example. Again with the issue above, I would double check the node, npm, and webdriver-manager versions. If you are still on Chrome 73, I would refer to version 73.0.3683.68. This can be done with webdriver-manager update --versions.chrome 73.0.3683.68. If you are still on webdriver-manager 12.0.x, it would download chromedriver 2.46 (webdriver-manager update --versions.chrome 2.46) which should work for version 73.

@raymonsaadalla See the above comment on version 73. You can either use Chromedriver 73.0.3683.68 or 2.46.

@XL175816 and @Priyankajoshipj I was able to get this to work with my simple example: https://github.com/cnishina/protractor542-chrome74 When did these tests work previously? Are you using async / await? Is the first website you are directing to not an Angular page?

vsravuri commented 5 years ago

Please check if Protractor is installed globally. Try removing node_modules folder and try again. I tested with async / await and didn't run into these issues with webdriver-manager 12.1.4. My node version is 10.15.3

vsravuri commented 5 years ago

You can also try deleting package.lock.json and do npn install again

ViieeS commented 5 years ago

Also try npm dedupe command. It fixes the bug with webdriver-manager version, if you install it manually.

ghost commented 5 years ago

We tried a couple times @vsravuri's suggestion to remove the node_modules folder and reinstall Protractor and webdriver-manager. We also tried deleting package.lock.json and doing "npm install" again.

@cnishina Our tests worked until Monday (5/6) afternoon. They worked all day until Google Chrome automatically updated to version 74; then they all failed, including the ones we had just successfully run minutes before. None of our scripts have async/await. And indeed, the first website we direct to is an Angular page.

vsravuri commented 5 years ago

Are you using Node 10.15.3? What's the error you see when you run the test? What's the output of webdriver-manager update?

shihuawang commented 5 years ago

Hi cnishina, The version 74 + webdriver-manager 12.1.4 + ChromeDriver 74 + nodejs 6.x + Protractor 5.4.2 does not work for us.

shihuawang commented 5 years ago

This happened several time to us when chrome stable version upgraded, and every time it's fixed later. But this time it hasn't been fixed. I previously said it fixed at one time which was my misunderstanding. So it's never fixed for 74.

shihuawang commented 5 years ago

At one time, I can get it work by install 73, but now it doesn't work.

The 73 that I previously installed works well, but not work with new installation.

shihuawang commented 5 years ago

And the cause for the failure is not the exception. It might has to do with timeout of a process, might be something else.

shihuawang commented 5 years ago

Hi vsravuri, Protractor is installed globally, and most of other cases worked. And before upgrade to 74 it still worked. also my previous installation with 73 still works, but we need to install on new docker for official nightly test. Our project has all been delayed due to this issue.

shihuawang commented 5 years ago

Hi vsravuri, my error is failed to create a new record which experience timeout with one of step, but it still should be created. and it used to worked until chrome 74. At one time, the 73 didn't work, but later it was fixed. Can you fix 74 in the same way?

shihuawang commented 5 years ago

Before 74, we can always reverse to older version to get it to work. But no luck this time.

shihuawang commented 5 years ago

I found that clearing browser cache (manually) may resolve my application's timeout issue, but when I add it to protractor it doesn't seem clear the cache. Can you advice me how to clear cache in protractor. The one I found on web doesn't work for me.