user7677010
user7677010

Reputation:

Type 'By' has no properties in common with type 'Locator'

I have issue when i try rebuild my project , i get following error:

Type 'By' has no properties in common with type 'Locator'


enter image description here


Can someone please point me in the right direction?

Upvotes: 7

Views: 3742

Answers (1)

bjorkblom
bjorkblom

Reputation: 1959

This is a bug in Protractor 4.x / Webdriver. the element method expects a Locator but by.css returns a webdriver.by object. To fix this compilation error you need to cast it to a Locator like:

import { Locator } from 'protractor/built/locators';
...
element(<Locator>by.css('h1'))

Upvotes: 10

Related Questions