Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Protractor 6 TypeScript issue - compilation issue 6.0.0 #5192

Open
Delagen opened this issue Mar 27, 2019 · 23 comments
Open

Protractor 6 TypeScript issue - compilation issue 6.0.0 #5192

Delagen opened this issue Mar 27, 2019 · 23 comments

Comments

@Delagen
Copy link

Delagen commented Mar 27, 2019

Bug report

  • Node Version: 11.12.0
  • Protractor Version: 6.0.0
  • Operating System and Version Windows 10
.../protractor/built/index.d.ts(7,10): error TS2305: Module '"selenium-webdriver"' has no exported member 'Actions'.

protractor/built/index.d.ts(22,46): error TS7016: Could not find a declaration file for module 'selenium-webdriver/lib/command'. '.../selenium-webdriver/lib/command.js' implicitly has an 'any' type.
  Try `npm install @types/selenium-webdriver` if it exists or add a new declaration (.d.ts) file containing `declare module 'selenium-webdriver/lib/command';`

.../protractor/built/ptor.d.ts(5,26): error TS7016: Could not find a declaration file for module 'selenium-webdriver/lib/command'. '.../selenium-webdriver/lib/command.js' implicitly has an 'any' type.
  Try `npm install @types/selenium-webdriver` if it exists or add a new declaration (.d.ts) file containing `declare module 'selenium-webdriver/lib/command';`

.../protractor/built/ptor.d.ts(25,31): error TS2339: Property 'Actions' does not exist on type 'typeof import("selenium-webdriver")'.

.../protractor/built/ptor.d.ts(33,17): error TS2307: Cannot find module './selenium-webdriver/lib/input'.
@Delagen Delagen changed the title TypeScript compilation issue TypeScript compilation issue 6.0.0 Mar 27, 2019
@Delagen
Copy link
Author

Delagen commented Mar 27, 2019

Seems found typings in your project. Try to use them

@sbley
Copy link

sbley commented Mar 27, 2019

I can confirm the last error:

node_modules/protractor/built/ptor.d.ts:33:17 - error TS2307: Cannot find module './selenium-webdriver/lib/input'.

The folder node_modules/protractor/built/selenium-webdriver does not contain a lib folder. It contains only two files: locators.js and webdriver.js-

  • Node Version: 8.9.4
  • Protractor Version: 6.0.0
  • Operating System and Version: Windows 10

@Delagen
Copy link
Author

Delagen commented Mar 27, 2019

@sbley git source contains ts definitions, looks like excluded from package by .npmignore or something else.

@sbley
Copy link

sbley commented Mar 27, 2019

I created a pull request #5193 to add the typings as part of the prepublish task.

@Delagen
Copy link
Author

Delagen commented Mar 27, 2019

Seems need also correct @types/selenium-webdriver or supply paths for TS module resolution

@cnishina
Copy link
Member

You do not need @types/selenium-webdriver since it was removed from Protractor 6. As far as I know there are no versions that support version 4. There's an issue already discussing removing it locally once we publish our types to DefinitelyTyped.

@cnishina
Copy link
Member

Hmmmm... okay looking at the PR, this is an issue. Thanks for the PR! I'll look into it when I get back from vacation.

@JonWallsten
Copy link

JonWallsten commented Mar 28, 2019

Just wanted to report I got the same issue. Can't even build our production build with @ngtools/webpack since it's somehow stumbles upon this d.ts file.

Edit: turns out I include our spec files in the compilation process. That's how it was found.

@cnishina cnishina changed the title TypeScript compilation issue 6.0.0 Protractor 6 TypeScript issue - compilation issue 6.0.0 Mar 29, 2019
@cnishina
Copy link
Member

cnishina commented Mar 29, 2019

Yes. This is not working. I tried to get Protractor to work without publishing to DefinitelyTyped. I went on vacation after publishing. I'm sorry that I didn't notice this sooner.

@cnishina
Copy link
Member

Root issue here is that I tried to roll out my own typings with the intent of releasing Protractor 6 without releasing types to DefinitelyTyped. After some experimentation, even if the types are in the node_modules/protractor/built/lib/selenium-webdriver directory with the tsconfig pointing to these files as "selenium-webdriver" typings, it still does not work.

I'll have a PR for DefinitelyTyped/selenium-webdriver ready to go tomorrow and will also address some of these other issues.

@Delagen
Copy link
Author

Delagen commented Mar 29, 2019

@cnishina Some protractor typings use direct import via 'selenium-webdriver/...' so types which does not declare this modules may not work. Moreover some code use relative import of typings via relative path './selenium-webdriver'

@sbley
Copy link

sbley commented Mar 29, 2019

After some experimentation, even if the types are in the node_modules/protractor/built/lib/selenium-webdriver directory with the tsconfig pointing to these files as "selenium-webdriver" typings, it still does not work.

Adding the typings during the prepublish task (PR above) solved my problem. I didn't have to point to the typings within tsconfig.

@cnishina
Copy link
Member

@sbley Alright let me revisit this. I tried this out and didn't get this to work.

@Delagen Do you know where you found this?

@Delagen
Copy link
Author

Delagen commented Mar 29, 2019

@cnishina Look at selenium-webdrive4 folder *.d.ts files in original repo

@cnishina
Copy link
Member

@sbley I could not get this to work in a sample project. I think the best bet is the DefinitelyTyped route. Also this is probably the right route without hacking in something to get it to work.

Speaking of getting things to work, I tagged the latest Protractor to 5.4.2 since that version is pretty stable.

@Delagen I did a word search and did not find these *.d.ts. files that reference the path './selenium-webdriver'

@Delagen
Copy link
Author

Delagen commented Mar 30, 2019

@cnishina https://github.com/angular/protractor/blob/master/lib/ptor.ts#L5 for example of direct import based on library structure
Also. Install NPM package and look at built/ptor.d.ts

...
Key: import("./selenium-webdriver/lib/input").IKey;
...

For now issue can be temporary resolved by placing *.d.ts files from source in selenium-webdriver folder of installed npm package and placing something like this in tsconfig.json paths section

	"selenium-webdriver": [
		"node_modules/protractor/built/selenium-webdriver"
		],
	"selenium-webdriver/*": [
		"node_modules/protractor/built/selenium-webdriver/*"
	]

But I still cannot start protractor with Chrome 75 taking this:

I/direct - Using ChromeDriver directly...
[09:19:19] E/launcher - Error: WebDriverError: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18865 x86_64)
    at Object.checkLegacyResponse (...\node_modules\selenium-webdriver\lib\error.js:585:15)

@cnishina
Copy link
Member

@Delagen So let's table this for now. Julie and I discussed this today about modifying the tsconfig as a workaround. The conclusion we came up with is that the right thing to do is to release to DefinitelyTyped. So for this last portion (Chrome 75! You are from the future! 😄), could you open up a new bug about this? Also could you try the same issue with 5.4.2? Thanks!

@cnishina
Copy link
Member

cnishina commented Apr 7, 2019

#5213 should resolve this. We will do another release at 6.0.0-beta.1 and wait to do a release when things appear stable.

@AugustusKling
Copy link

#5213 looks like a good approach to fix this. Pulling from @types/selenium-webdriver, as users of Protractor would, ensures that there are no surprises due to differing type definitions.

I'm somewhat confused about the versioning though:

I would appreciate some clarification if Protractor 6.0.0 is the way to go for ordinary users of Protractor or if it's supposed to be a preview release only.

About Protractor 5.4.2 and the future Chrome 75 or any other Chrome version after 73: It does not work.
Protractor 5.4.2 depends on a version of webdriver-manager that cannot download ChromeDriver versions newer than 2.46 because it fails to process the newer version numbers such as 73.0.3683.68. The new ChromeDriver versions are not accepted by https://github.com/angular/webdriver-manager/blob/12.1.1/lib/binaries/chrome_xml.ts#L110
This leaves users of Protractor 5.4.2 being unable to test against Chrome 74 or later as pointed out in angular/webdriver-manager#353 (comment). This affects direct connections to the locally installed Chrome at least.

@cnishina
Copy link
Member

So here's some hindsight thoughts on release 6. I think I've written similar comments in other GitHub issue threads already:

So I tried to release 6.0.0...

6.0.0 was released and I was definitely disappointed that there were issues. There are a lot of changes internally that happened like removing q and selenium-webdriver control flow.

The original plan was to use selenium-webdriver type definitions we created and do a release of Protractor before publishing them to DefinitelyTyped. When it was released, it did not work for our TypeScript community. So I put in a PR to DefinitelyTyped to publish selenium-webdriver 4 type definitions which relates to PR #5213 that you referenced.

Since this did not work we set the latest (on npmjs) to 5.4.2 so if you were doing an npm install protractor, you should not get 6.0.0.

Moving forward we will do beta releases

The next version is 6.0.0-beta.1 for release. Should it be 6.0.1-beta.1 since 6.0.0 is sort of released? Version numbers are hard and I'll ask Julie what she thinks. The next release will be a beta version to work out the bugs. We will let the Angular core team to handle the official releases.

Selenium-webdriver client

selenium-webdriver 4.0.0-alpha.1 has been out for over a year and they have not had release since. This appears to be stable. I do not think this is too risky which is why we are trying to get Protractor@6.x.x out the door.

Limitations on Protractor@5.4.2

I agree that version 5.4.2 does have limitations. Some of those limitations:

  • it relies on the control flow
  • as browser drivers change, the selenium-webdriver client might eventually not work,
  • it also depends on webdriver-manager@12.x.x that will eventually not work with the new ChromeDriver versioning.

Some of the main motivations behind the work I've done for 6.x.x is to address the control flow deprecation, to update to a newer selenium-webdriver client and also address webdriver-manager limitations.

I hope that helps.

@kylecordes
Copy link

(I have not consulted server documentation as I write this.)

As a consumer of packages I definitely assume that 6.0.0-beta.1 is a beta during development toward 6.0.0, not something happening after 6.0.0.

@cnishina
Copy link
Member

Thanks @kylecordes. 6.0.1-beta.1 it is!

@cnishina
Copy link
Member

I think there's a lot of context about Protractor 6 and the compilation issue. I'm going to lock this conversation so I can focus on fixing stuff. 😄

@angular angular locked as too heated and limited conversation to collaborators Apr 11, 2019
@cnishina cnishina added this to the Release version 6.0.1-beta.1 milestone Apr 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants