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

vsravuri commented 5 years ago

You need to check if there is any issue with ChromeDriver 74 and your automation script. To clear browser cache, you need to choose if you want to delete cookies, local storage or session storage.

Try this browser.executeScript('window.sessionStorage.clear();'); browser.executeScript('window.localStorage.clear();'); browser.manage().deleteCookie("test_cookie");

shihuawang commented 5 years ago

Hi vsravuri, I later got my clear cache worked, some how it has to be in a function as the below link suggested: https://stackoverflow.com/questions/45218022/how-to-clear-a-browser-cache-in-protractor?rq=1

So this is a work around to my particular issue. But I do hope someone can fix it to handle this situation as how chrome browser do, behave the same way as manual test. This has been a problem in recent several chrome releases and all finally got fixed, except 74.

ghost commented 5 years ago

@Priyankajoshipj and I have the following versions of applications:

Running our scripts still produces the same error as before, with Chrome being blank. (To reiterate myself from above, the browser appears but is blank, never even able to get to https://localhost where our application is, and hangs like that forever. The test times out, and the browser still stays like that until we manually close it.) Because it hangs, the cmd does not say anything (just a blinking cursor), so we don’t even know what the error is.

Clearing the Chrome cache before running a script does not work for us. It has the same result. And our tests should not clear the cache anyway.

We did find something that could be a lead. We were able to run @cnishina ’s simple test mentioned above and, after experimenting around, found a way to get our tests to work. It requires using async/await; we’d have to add “await” in front of every line… Without async/await, Chrome either sometimes gets to https://localhost then immediately closes and says “Error while waiting for Protractor to sync with the page” or sometimes doesn’t get to localhost at all (the forever hanging blank browser I attached above).

However, changing all the code in our scripts would represent a very significant effort. And as mentioned before, unfortunately downgrading Chrome to version 73 is not an option for us. Hope Chrome version 74 can be fixed.

cnishina commented 5 years ago

@XL175816 going forward we need to make everything async / await because of the control flow deprecation. If async / await is working, it might be a good idea to start the that engineering effort now to upgrade your tests.

@shihuawang Please open up a new bug and add more information. How does it fail? What were you doing? What's the error message? Do you have a sample set of code? What environment are you running your tests on? Reading through the messages from above, I am not sure where to start or how to help.

cnishina commented 5 years ago

I'm also going to lock down this conversation since this is resolved. I am leaving it open just in case someone still runs into this issue. If you are running into issues with Protractor that you feel are issues with the framework, feel free to open up a new issue. If you are looking for support help, please ask it here: https://stackoverflow.com/questions/tagged/protractor