2016-12-04 9 views
0

我設置了Cucumber,Webdriver-IO和Appium。一切似乎都在互相交談,但是我在試圖導航到http://google.com時收到Error: no such session「錯誤:沒有這樣的會話」Webdriver-IO,Appium

在Android設備上打開Chrome瀏覽器,然後關閉它非常快。

webdriverio.js

//webdriverio.js 
let client = WebDriverIO.remote({ 
    desiredCapabilities: { 
     platformName: 'Android',       
     browserName: 'chrome',       
     deviceName: 'test', 
    }, 
    host: 'localhost',         
    port: 4723,          
    waitForTimeout: 120 * 1000, 
}); 

global.client = client; 

module.exports = function() { 
    this.registerHandler('BeforeFeatures', function(event, done) { 
    client.init().call(done); 
    }); 

    this.registerHandler('AfterFeatures', function(event, done) { 
    client.end().call(done); 
    }); 
}; 

env.js

// env.js 
module.exports = function() { 
    // added because default 50000 ms was long enough 
    this.setDefaultTimeout(60 * 1000); 
}; 

search_steps.js

// search_steps.js 
module.exports = function() { 
    this.Given('I have visited Google', function (done) { 
    client 
     .url('http://google.com') 
     .call(done); 
    }); 

    this.When('I search for {arg1:stringInDoubleQuotes}', function (arg1, done) { 
    // Write code here that turns the phrase above into concrete actions 
    client 
     .setValue('input[name="q"]', 'Kittens') 
     .call(done); 
    }); 


    this.Then('I see {arg1:stringInDoubleQuotes}', function (arg1, done) { 
     // Write code here that turns the phrase above into concrete actions 
     client 
      .getValue('input[name="q"]').then(function(text){ 
       expect('Kittens').to.eql(text); 
      }) 
      .call(done); 
    }); 


}; 

回答

0

問題是與我的Mac版本的Appium(1.3.5)一起發貨的chromedriver 2.21.371459。我下載了最新版本的chromedriver,並覆蓋了Appium附帶的現有版本。請參閱這裏的答案Chrome opens for a second and the crashes for windows。對於Mac,Appium附帶的chromedriver exec的位置是。 /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac