所有教程都建议我在webdriver-manager更新之后和执行测试之前执行以下命令:
webdriver-manager开始
根据webdriver-manager man的说法,start命令将“启动selenium服务器”.确实,一旦我运行上述命令,我就可以在http://127.0.0.1:4444/wd/hub看到一些东西
我的问题是:上面有必要吗?
我目前在没有上述命令的情况下运行测试.
我所做的就是:
webdriver-manager更新
PHP -S localhost:8000 -t dist /
量角器./test/protractor.config.js
我的测试按预期运行,即使我已经排除了webdriver-manager的启动.
有人可以解释为什么webdriver-manager启动是必要的吗?
:编辑:
我的量角器/ fooTests.js:
exports.config = { directConnect: true,capabilities: { 'browserName': 'chrome' },specs: ['protractor/fooTests.js'],jasmineNodeOpts: { showColors: true,defaultTimeoutInterval: 30000 } };
我的量角器/ fooTests.js:
describe('test for the bar code',function() { it('should login',function() { browser.get('http://localhost:8000'); element(by.model('password')).sendKeys('123456'); element(by.css('[type="submit"]')).click(); }); it('should inspect element ',function() { expect(element(by.id('foo-script')).isPresent()).toBe(true); console.log('Login Success'); }); });
webdriver-manager start
正在启动Selenium.
有3个基本选项:
> directConnect.这使得量角器直接与selenium驱动程序通信,而不使用Selenium服务器.但是,此选项的功能有限:
directConnect: true – Your test script communicates directly Chrome Driver or Firefox Driver,bypassing any Selenium Server. If this is true,settings for seleniumAddress and seleniumServerJar will be ignored. If you attempt to use a browser other than Chrome or Firefox an error will be thrown.
>连接到已运行的selenium服务器(本地或远程),由seleniumAddress指定.可以使用webdriver-manager启动脚本启动服务器.
>从测试脚本启动服务器.
您可以浏览文档https://github.com/angular/protractor/blob/master/docs/server-setup.md中的所有选项