我設置了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);
});
};