0

Mocha と webdriverjs を発見した後readme.mdhttps://github.com/camme/webdriverjsを読んだ後、試してみたかったので、簡単なテストから始めました。

var webdriverjs = require("webdriverjs"),
    client = webdriverjs.remote(), 
    expect = require("chai").expect;

suite('Functional tests', function(done) {
    setup(function(done) {
            client.init().url('http://www.google.com', done);
    });
    test('test if you can open a firefox page', function() {
            var inputType = client.getAttribute('#searchtext_home', 'type');
            expect(inputType).to.be.a('string');
            console.log(myString);
    });
    teardown(function(done) {
            client.end(done);
            //done();
    });
});

Google の入力要素を取得し、その型がテキストであることを期待します。inputType最終的に変数内のオブジェクトになります。

AssertionError: { Object (sessionId, desiredCapabilities, ...) } が文字列であると予想されます

4

1 に答える 1

1

からオブジェクトを返しますclient.getAttribute()。したがって、次のようなコールバック関数である 3 番目のパラメーターを使用する必要があります。

test('test if you can open a firefox page', function(done) {
    client.getAttribute('#searchtext_home', 'type', function(err, inputType) {
        expect(inputType).to.be.a('string');
        done();
    });
});

詳細なサンプル コードはこちらを参照してください。

于 2013-12-23T13:46:25.140 に答える