Webdriver.io与NoSessionIdError崩溃 [英] Webdriver.io crashes with NoSessionIdError

查看:128
本文介绍了Webdriver.io与NoSessionIdError崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让webdriver.io和Jasmine工作。

I'm trying to get webdriver.io and Jasmine working.

关注他们的示例,我的脚本位于 test / specs / first / test2.js (根据配置)并包含:

Following their example, my script is at test/specs/first/test2.js (in accordance with the configuration) and contains:

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);
    });
});

我使用wdio作为测试运行器,并使用交互式设置进行设置。该配置是自动生成的,而且非常简单,所以我认为不需要发布它。

I'm using wdio as the test runner, and set it up using the interactive setup. That config is automatically-generated and all pretty straightforward, so I don't see a need to post it.

在另一个终端窗口中,我正在运行selenium-server-和Java-7.47.1.jar与Java 7.我的计算机上安装了Firefox(在测试运行时它茫然启动),我的计算机运行的是OS 10.10.5。

In another terminal window, I am running selenium-server-andalone-2.47.1.jar with Java 7. I do have Firefox installed on my computer (it blankly starts when the test is run), and my computer is running OS 10.10.5.

当我启动测试运行器时会发生这种情况:

This is what happens when I start the test runner:

$ 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)


$

我发现这很奇怪且莫名其妙,特别是考虑到它甚至打印会话ID。

I find this very strange and inexplicable, especially considering that it even prints the session ID.

任何想法?

推荐答案

请查看wdio测试运行器上的文档。您不需要自己使用init创建实例。 wdio测试运行器负责为您创建和结束会话。

Please check out the docs on the wdio test runner. You don't need to create an instance using init on your own. The wdio test runner takes care on creating and ending the session for you.

您的示例涵盖了独立的WebdriverIO用法(没有testrunner)。您可以找到使用wdio 此处的示例。

Your example covers the standalone WebdriverIO usage (without testrunner). You can find examples which use wdio here.

为了澄清:有两种使用WebdriverIO的方法。您可以自己将其嵌入到测试系统中(将其作为独立/或作为刮板使用)。然后你需要处理诸如创建和结束实例之类的事情或者并行运行它们。使用WebdriverIO的另一种方法是使用名为wdio的测试运行器。 testrunner获取一个配置文件,其中包含有关测试设置的大量信息,并在Sauce Labs上生成实例更新作业信息等。

To clarify that: there are two ways of using WebdriverIO. You can embed it in your test system by yourself (using it as standalone / or as a scrapper). Then you need to take care of things like create and end an instance or run those in parallel. The other way to use WebdriverIO is using its test runner called wdio. The testrunner takes a config file with a bunch of information on your test setup and spawns instances updates job information on Sauce Labs and so on.

这篇关于Webdriver.io与NoSessionIdError崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆