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

'typings' missing from Protractor 3.3.0 package.json on NPM #3350

Closed
jan-molak opened this issue Jul 11, 2016 · 7 comments
Closed

'typings' missing from Protractor 3.3.0 package.json on NPM #3350

jan-molak opened this issue Jul 11, 2016 · 7 comments

Comments

@jan-molak
Copy link
Contributor

Assume a test utilising several browsers, for example one verifying interaction between chat clients.

The docs say that in order to get hold of the element function, one can use the element property of the browser object:

var browser2 = browser.forkNewDriverInstance();
var element2 = browser2.element;

To my current understanding, the difference between the global element helper and browser.element is that the former is an instance of protractor.Element while the latter is a protractor.ElementFinder.

I'm not sure if this differentiation is intentional or if it's a bug?

The effect of it is that in a Typescript test, one can't simply refer to the .all helper using:

browser.element.all(...)

but instead has to do this to make the transpiler happy:

(<any> browser.element).all(...)

Shouldn't the element field of the browser object be of type protractor.Element instead of protractor.ElementFinder?

Thanks,
Jan

@cnishina
Copy link
Contributor

cnishina commented Jul 11, 2016

I took a look at this and after some quick checking, it is not a bug. Hopefully this will help clarify the types for the items in question:

  • the property element in the global namespace is of type ElementHelper
  • browser.element is of type ElementHelper
  • element(...) returns a type of ElementFinder
  • browser.element.all(...) returns a type of ElementArrayFinder

when forking a new driver instance:

let browser2 = browser.forkNewDriverInstance();   // this is of type Browser
let element2 = browser2.element;                  // this is an ElementHelper
let foo = element2(by.css('foo'))                 // by.css(...) returns a Locator, element2(...) returns an ElementFinder

Also, there is no type Element. Are you getting the typings off of master? How are you getting your global imports? Have you tried the example for typescript?

@jan-molak
Copy link
Contributor Author

jan-molak commented Jul 11, 2016

Hey Craig and thanks for the quick response!

I think I see what's happening:

  • I'm using Protractor 3.3.0 from npm (according to NPM it's been published 3 months ago)
    screen shot 2016-07-11 at 19 21 41
  • since Protractor 3.3.0's package.json does not specify the typings key, TypeScript can't find them (I see that this has been fixed since then and the typings key is present as of 20 days ago)
  • because TypeScript couldn't find the typings, I installed them using the Typings npm module, and those appear to be older and incompatible with the current master of Protractor 3.3.0.

Given the above, could you please advise when is the package.json fix going to make it to the npm?

Many thanks,
Jan

@jan-molak jan-molak changed the title browser.element.all not available in multi-browser tests? 'typings' missing from package.json on NPM Jul 11, 2016
@jan-molak jan-molak changed the title 'typings' missing from package.json on NPM 'typings' missing from Protractor 3.3.0 package.json on NPM Jul 11, 2016
@cnishina
Copy link
Contributor

It will happen soon! Possibly today.

@jan-molak
Copy link
Contributor Author

Sweet! Much appreciated 👍

@jan-molak
Copy link
Contributor Author

jan-molak commented Jul 13, 2016

Thanks for the 4.0.0, Craig! It's a huge improvement. The only thing that's now gone missing from the built/index.d.ts typings is the ProtractorPlugin class definition. I'll raise a separate ticket for that.

Update: raised tickets #3365 and #3367. #3366 seems related too.

@cnishina
Copy link
Contributor

ProtractorPlugins are now part of typings. This will be addressed in the next hot fix.

@jan-molak
Copy link
Contributor Author

Great stuff, looking forward to the release!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants