2

我使用webdriver(http://webdriver.io/),獨立硒,摩卡書寫我的測試用例。測試用例特定於chrome,因此我使用了chromedriver。從chromedriver啓動時修改標誌

啓動時我想禁用「touch-events」和「touch-optimized-ui」標誌,否則我的測試用例會失敗。

每當chromedriver啓動瀏覽器時,它將以默認選項開始。 任何人都可以爲我提供解決方案嗎?什麼可以添加到下面的代碼來禁用這些標誌?或者也許有其他解決方案?

示例代碼:

var webdriverjs = require('./webdriverjs/index'), 
    assert  = require('assert'); 

describe('my webdriverjs tests', function(){ 

    this.timeout(99999999); 
    var client = {}; 

    before(function(done){ 
      client = webdriverjs.remote({ desiredCapabilities: {browserName: 'chrome'} }); 
      client.init(done); 
    }); 

    it('sample test',function(done) { 
     client 
      .url('http://localhost:3030/subset/index') 
      .call(done) 
    }); 

    after(function(done) { 
     client.end(done); 
    }); 
}); 

回答

2

您可以在您需要的能力範圍之內傳遞任何鍍鉻標誌如下:

client = webdriverjs.remote({ 
    desiredCapabilities: { 
     browserName: 'chrome', 
     chromeOptions: { 
      args: ['touch-events','touch-optimized-ui'] 
     } 
    } 
});