我使用命令appium
运行mocha ios-safari.js
iphone测试,它出错:
您请求的环境不可用
从appium samples
下载ios-safari.js
的示例:
"use strict";
require("./helpers/setup");
var wd = require("wd"),
_ = require('underscore'),
serverConfigs = require('./helpers/appium-servers');
describe("ios safari", function () {
this.timeout(300000);
var driver;
var allPassed = true;
before(function () {
var serverConfig = process.env.SAUCE ?
serverConfigs.sauce : serverConfigs.local;
driver = wd.promiseChainRemote(serverConfig);
require("./helpers/logging").configure(driver);
var desired = _.clone(require("./helpers/caps").ios81);
desired.browserName = 'safari';
if (process.env.SAUCE) {
desired.name = 'ios - safari';
desired.tags = ['sample'];
}
return driver.init(desired);
});
after(function () {
return driver
.quit()
.finally(function () {
if (process.env.SAUCE) {
return driver.sauceJobStatus(allPassed);
}
});
});
afterEach(function () {
allPassed = allPassed && this.currentTest.state === 'passed';
});
it("should get the url", function () {
return driver
.get('https://www.google.com')
.sleep(1000)
.waitForElementByName('q', 5000)
.sendKeys('sauce labs')
.sendKeys(wd.SPECIAL_KEYS.Return)
.sleep(1000)
.title().should.eventually.include('sauce labs');
});
it("should delete cookie passing domain and path", function () {
var complexCookieDelete = function(name, path, domain) {
return function() {
path = path || '|';
return driver.setCookie({name: name, value: '', path: path,
domain: domain, expiry: 0});
};
};
return driver
.get('http://en.wikipedia.org')
.waitForElementByCss('.mediawiki', 5000)
.allCookies() // 'GeoIP' cookie is there
.deleteCookie('GeoIP')
.allCookies() // 'GeoIP' is still there, because it is set on
// the .wikipedia.org domain
.then(complexCookieDelete('GeoIP', '/', '.wikipedia.org'))
.allCookies() // now 'GeoIP' cookie is gone
.sleep(1000);
});
});
appium
日志如下:
info: [debug] Error: Could not find a device to launch. You requested
'iPhone 6 (8.1 Simulator)',
but the available devices were: [
"iPad 2 (8.3 Simulator) [2F86D724-B8D6-4F22-B5E8-97B437C9ACFB]",
"iPad Air (8.3 Simulator) [8A07B826-AF59-4FC4-BC8E-21B37ADAF539]",
"iPad Retina (8.3 Simulator) [9C589CB6-1CF4-437E-83DB-1270DB1599FC]",
"iPhone 4s (8.3 Simulator) [31F567A4-5346-4E1A-B414-C45062105964]",
"iPhone 5 (8.3 Simulator) [E820B152-B5B4-4A79-B9DE-3A1F49859662]",
"iPhone 5s (8.3 Simulator) [5A07EBE7-264A-4571-BA9E-1F17C882ADE3]",
"iPhone 6 (8.3 Simulator) [58856942-BD3F-45C6-9B1B-93102851B37E]",
"iPhone 6 Plus (8.3 Simulator)
由于我已将X code
更新为最新版本,因此我似乎应该在配置中的某个位置将设备名称从iPhone 6 (8.1 Simulator)
更改为iPhone 6 (8.3 Simulator) [58856942-BD3F-45C6-9B1B-93102851B37E]
。但是我应该在哪里做到这一点 - 无法理解。
答案 0 :(得分:0)
启动Appium会话时指定目标设备。在命令行中,使用' - device-name'参数。在Appium UI中,您可以在iOS选项卡中指定所需的设备。我发现这个名字有点挑剔。我已经取得了最大的成功,因为它可以区分设备。 IOW,试试iPhone 6'或者' iPhone 5(8.3模拟器)'而不是整个字符串。