2014-02-11 37 views
7

错误:无法找到模块“硒的webdriver” 我已经在全球范围使用 NPM安装-g量角器 webdriver的经理更新安装量角器和硒的webdriver量角器E2E测试错误:无法找到模块“硒的webdriver”

var webdriver = require('selenium-webdriver'); 


describe('modes of failure', function() { 
    it('should fail to find a non-existent element', function() { 
    browser.get('index.html#/form'); 

    // Run this statement before the line which fails. If protractor is run 
    // with the debugger (protractor debug debugging/conf.js), the test 
    // will pause after loading the webpage but before trying to find the 
    // element. 
    browser.debugger(); 

    // This element doesn't exist, so this fails. 
    var nonExistant = element(by.binding('nopenopenope')).getText(); 
    }); 

    it('should fail to use protractor on a non-Angular site', function() { 
    browser.get('http://www.google.com'); 
    }, 20000); 

    it('should fail an assertion', function() { 
    browser.get('index.html#/form'); 

    var greeting = element(by.binding('{{greeting}}')); 

    expect(greeting.getText()).toEqual('This is not what it equals'); 
    }); 
}); 
+0

你为什么要要求webriver这样? – glepretre

+0

你可以试着用这个命令行来运行这个例子吗? '量角器node_modules /量角器/ example/conf.js' – glepretre

回答

0
当你输入

webdriver-manager 

到终端

,将这些有用的选项出现:

webdriver-manager 
Usage: webdriver-manager <command> 
Commands: 
    update: install or update selected binaries 
    start: start up the selenium server 
    status: list the current available drivers 

你试过update, start,status?

+0

是的,但仍显示相同的错误。 – user3061796

1

你尝试删除var webdriver = require('selenium-webdriver');

你不应该需要它,你可以在你的测试通过browser

browser this is the a wrapper around an instance of webdriver. Used for navigation and page-wide information.

访问(从Getting started - Protractor docs报价)

如果您已经安装使用webdriver-manager update硒独立的服务器,和开始它与webdriver-manager start,你所要做的就是运行你的测试使用

protractor path/to/your/protractor-conf.js 
0

尝试使用独立的选项:

$ webdriver-manager start --standalone 
2

您需要安装节点模块:

npm i selenium-webdriver --save-dev