Tra*_*vis 5 javascript selenium webdriver-io
我正在尝试让webdriver.io和Jasmine工作.
按照他们的示例,我的脚本处于test/specs/first/test2.js(根据配置)并包含:
var webdriverio = require('webdriverio');
describe('my webdriverio tests', function() {
var client = {};
jasmine.DEFAULT_TIMEOUT_INTERVAL = 9999999;
beforeEach(function() {
client = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'} });
client.init();
});
it('test it', function(done) {
client
.url("http://localhost:3000/")
.waitForVisible("h2.btn.btn-primary")
.click("h2.btn.btn-primary")
.waitForVisible("h2.btn.btn-primary")
.call(done);
});
afterEach(function(done) {
client.end(done);
});
});
Run Code Online (Sandbox Code Playgroud)
我使用wdio作为测试运行器,并使用交互式设置进行设置.该配置是自动生成的,并且非常简单,因此我认为不需要发布它.
在另一个终端窗口中,我正在使用Java 7运行selenium-server-andalone-2.47.1.jar.我的计算机上安装了Firefox(它在运行测试时茫然启动),而我的计算机正在运行OS 10.10. 5.
这是我启动测试运行时发生的情况:
$ wdio wdio.conf.js
=======================================================================================
Selenium 2.0/webdriver protocol bindings implementation with helper commands in nodejs.
For a complete list of commands, visit http://webdriver.io/docs.html.
=======================================================================================
[18:17:22]: SET SESSION ID 46731149-79aa-412e-b9b5-3d32e75dbc8d
[18:17:22]: RESULT {"platform":"MAC","javascriptEnabled":true,"acceptSslCerts":true,"browserName":"firefox","rotatable":false,"locationContextEnabled":true,"webdriver.remote.sessionid":"46731149-79aa-412e-b9b5-3d32e75dbc8d","version":"40.0.3","databaseEnabled":true,"cssSelectorsEnabled":true,"handlesAlerts":true,"webStorageEnabled":true,"nativeEvents":false,"applicationCacheEnabled":true,"takesScreenshot":true}
NoSessionIdError: A session id is required for this command but wasn't found in the response payload
at waitForVisible("h2.btn.btn-primary") - test2.js:21:14
/usr/local/lib/node_modules/webdriverio/node_modules/q/q.js:141
throw e;
^
NoSessionIdError: A session id is required for this command but wasn't found in the response payload
0 passing (3.90s)
$
Run Code Online (Sandbox Code Playgroud)
我觉得这很奇怪而且莫名其妙,特别是考虑到它甚至打印会话ID.
有任何想法吗?
请查看wdio 测试运行器上的文档。您不需要自己使用 init 创建实例。wdio 测试运行器负责为您创建和结束会话。
您的示例涵盖了独立的 WebdriverIO 用法(没有测试运行程序)。您可以在此处找到使用 wdio 的示例。
澄清一下:有两种使用 WebdriverIO 的方法。您可以自己将它嵌入到您的测试系统中(将其用作独立/或作为刮板)。然后,您需要处理诸如创建和结束实例或并行运行之类的事情。另一种使用 WebdriverIO 的方法是使用其名为 wdio 的测试运行程序。testrunner 获取一个配置文件,其中包含一系列有关您的测试设置的信息,并生成实例更新 Sauce Labs 上的作业信息等。
| 归档时间: |
|
| 查看次数: |
4674 次 |
| 最近记录: |