2013-12-23 59 views
0

發現摩卡和webdriverjs後,我想給它一個鏡頭,在閱讀readme.mdhttps://github.com/camme/webdriverjs,所以我開始了一個微不足道的測試。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(); 
    }); 
}); 

獲取谷歌的輸入元素,並期望它的類型是文本。 我以inputType變量結束了一個對象。

Asse田:預期{對象(的sessionId,desiredCapabilities,...)}是一個字符串

回答

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

查看更多詳細示例代碼here

相關問題