Typescript 量角器:将自定义定位器添加到全局命名空间
我想将自定义定位器$x添加到ElementFinder原型中,以便在脚本中使用它们。 想法是使用$x代替元素(by.xpath(“MyXPath”) elementHelper.ts 我计划像这样使用上面的代码: test.ts 这是行不通的。如何解决此错误:模块“量角器/内置”没有导出成员“$x”。Typescript 量角器:将自定义定位器添加到全局命名空间,typescript,protractor,Typescript,Protractor,我想将自定义定位器$x添加到ElementFinder原型中,以便在脚本中使用它们。 想法是使用$x代替元素(by.xpath(“MyXPath”) elementHelper.ts 我计划像这样使用上面的代码: test.ts 这是行不通的。如何解决此错误:模块“量角器/内置”没有导出成员“$x”。 import { element, by, ElementFinder,} from 'protractor'; declare module 'protractor/built' {
import { element, by, ElementFinder,} from 'protractor';
declare module 'protractor/built' {
export interface ElementFinder {
$x(text: string): ElementFinder;
}
}
ElementFinder.prototype.$x = function (selector) {
return element(by.xpath(selector));
};
export * from 'protractor'
import { $x } from 'protractor';
$x("my xpath here");