簡體   English   中英

Angular 2 - 量角器(e2e)運行時錯誤

[英]Angular 2 - protractor(e2e) runtime error

當我運行量角器時出現此錯誤

[15:47:46] E/launcher - Error: TSError: ? Unable to compile TypeScript
Conflicting library definitions for 'selenium-webdriver' found at 'G:/WebServers/home/smsc/SMSC2/modules/admin/node_modules/@types/selenium-webdriver/index.d.ts' and 'G:/WebServers/home/smsc/SMSC2/modules/admin
/node_modules/protractor/node_modules/@types/selenium-webdriver/index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict. (4090)

我重建並重新安裝量角器,但沒有。 我使用這個命令來運行量角器

npm run protractor

我閱讀了量角器的教程並編寫了像這里輸入鏈接描述這樣的測試。

describe('angularjs homepage todo list', function() {
    it('should add a todo', function() {
        browser.get('http://some-link/');

        console.log('Hi!');
    });
})

量角器在這個例子中工作正常,但不適用於打字稿。 做什么?

錯誤消息描述了問題:

在“G:/WebServers/home/smsc/SMSC2/modules/admin/node_modules/@types/selenium-webdriver/index.d.ts”和“G:/WebServers/home”中找到的“selenium-webdriver”庫定義沖突/smsc/SMSC2/modules/admin /node_modules/protractor/node_modules/@types/selenium-webdriver/index.d.ts'。 將正確的文件復制到“typings”文件夾以解決此沖突。 (4090)

您有兩個 selenium-webdriver 類型文件的實例。 Typescript 使用類型文件來幫助對使用 vanilla JS 庫的應用程序進行靜態類型檢查。

在這種情況下, @types/selenium-webdriver/index.d.ts文件描述了 selenium 導出成員的類型形狀(由量角器內部使用)。

您需要做的是確定要使用哪個版本的類型。

G:/WebServers/home/smsc/SMSC2/modules/admin/node_modules/@types/selenium-webdriver/index.d.ts
G:/WebServers/home/smsc/SMSC2/modules/admin/node_modules/protractor/node_modules/@types/selenium-webdriver/index.d.ts

這些很可能是同一個文件,只是在兩個位置。 只需將其中一個移動到您項目的打字位置即可:

 G:/WebServers/home/smsc/SMSC2/modules/typings/selenium-webdriver/index.d.ts

再深入一點,我幾乎會認為這是量角器的一個錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM