update WDIO test to v5 (#11919)

* update WDIO test to v5

* fix review
This commit is contained in:
Sai Krishna
2019-01-02 17:57:39 +00:00
committed by Dan Graham
parent 4a4f1cf20e
commit 4df45addc3
8 changed files with 69 additions and 108 deletions

View File

@@ -3,30 +3,21 @@ const androidOptions = require("../../helpers/caps").androidOptions;
const app = require("../../helpers/apps").androidApiDemos;
const assert = require("chai").assert;
androidOptions.desiredCapabilities.app = app;
androidOptions.capabilities.app = app;
describe("Create Android session", function() {
let client;
before(function() {
client = webdriverio.remote(androidOptions);
return client.init();
before(async() => {
client = await webdriverio.remote(androidOptions);
});
it("should create and destroy a session", function() {
return client
.sessions(function(res) {
assert.isAbove(res.value.length, 0);
})
.currentActivity(function(res) {
assert.equals(res.value, ".ApiDemos");
})
.getCurrentPackage(function(res) {
assert.equals(res.value, "io.appium.android.apis");
})
.end()
.sessions(function(res) {
assert.equals(res.value.length, 0);
});
it("should create and destroy a session", async function() {
const res = await client.status();
assert.isObject(res.build);
const current_package = await client.getCurrentPackage();
assert.equal(current_package, "io.appium.android.apis");
const delete_session = await client.deleteSession();
assert.isNull(delete_session);
});
});

View File

@@ -1,29 +1,23 @@
const webdriverio = require("webdriverio");
const androidOptions = require("../../helpers/caps").androidWebOptions;
const app = require("../../helpers/apps").androidApiDemos;
const assert = require("chai").assert;
describe("Create Chrome web session", function() {
let client;
before(function() {
client = webdriverio.remote(androidOptions);
return client.init();
before(async function() {
client = await webdriverio.remote(androidOptions);
});
after(function() {
return client.end();
after(async function() {
return await client.deleteSession();
});
it("should create and destroy Android browser session", async function() {
// Navigate to google.com
return client
.url("https://www.google.com")
.title(function(res) {
assert.equal(res.value, "Google");
})
.source(function(res) {
assert.match(/<html/g);
});
let client = await webdriverio.remote(iosOptions);
await client.url("https://www.google.com");
const title = await client.getTitle();
assert.equal(title, "Google");
});
});

View File

@@ -3,38 +3,31 @@ const iosOptions = require("../../helpers/caps").iosOptions;
const app = require("../../helpers/apps").iosTestApp;
const assert = require("chai").assert;
iosOptions.desiredCapabilities.app = app;
iosOptions.capabilities.app = app;
describe("Basic IOS interactions", function() {
let client;
beforeEach(function() {
client = webdriverio.remote(iosOptions);
return client.init();
beforeEach(async function() {
client = await webdriverio.remote(iosOptions);
});
afterEach(function() {
return client.end();
afterEach(async function() {
await client.deleteSession();
});
it("should send keys to inputs", function() {
return client
.waitForExist("~TextField1", 5000)
.element("~TextField1")
.setValue("Hello World!")
.getText("~TextField1", function(result) {
assert.equal(result.value, "Hello World!");
});
it("should send keys to inputs", async function() {
const elementId = await client.findElement("accessibility id","TextField1");
client.elementSendKeys(elementId.ELEMENT, "Hello World!");
const elementValue = await client.findElement("accessibility id","TextField1");
await client.getElementAttribute(elementValue.ELEMENT,"value").then((attr) => {
assert.equal(attr,"Hello World!");
});
});
it("should click a button that opens an alert", async function() {
return client
.waitForExist("~show alert", 5000)
.element("~show alert")
.click()
.waitForExist("~Cool title", 5000)
.getText("~Cool title", function(result) {
assert.equal(result.value, "Cool title");
});
const element = await client.findElement("accessibility id","show alert");
await client.elementClick(element.ELEMENT);
assert.equal(await client.getAlertText(),"Cool title\nthis alert is so cool.");
});
});

View File

@@ -3,34 +3,23 @@ const iosOptions = require("../../helpers/caps").iosOptions;
const app = require("../../helpers/apps").iosTestApp;
const assert = require("chai").assert;
iosOptions.desiredCapabilities.app = app;
iosOptions.capabilities.app = app;
describe("Create session", function() {
let client;
beforeEach(function() {
client = webdriverio.remote(iosOptions);
beforeEach(async function() {
client = await webdriverio.remote(iosOptions);
});
afterEach(function() {
return client.end();
});
it("should create and destroy IOS sessions", function() {
return client
.sessions(function(result) {
assert.equal(result.value.length, 0);
})
.sessions(function(result) {
assert.equal(result.value.length, 1);
})
.init()
.getAttribute("XCUIElementTypeApplication", "name", function(result) {
assert.equal(result.value, "TestApp");
})
.end()
.sessions(function(result) {
assert.equal(result.value.length, 0);
});
it("should create and destroy IOS sessions", async function() {
const res = await client.status();
assert.isObject(res.build);
const element = await client.findElement("class name","XCUIElementTypeApplication");
client.getElementAttribute(element.ELEMENT,"name").then((attr) => {
assert.equal(attr,"TestApp");
});
const destroySession = await client.deleteSession();
assert.isNull(destroySession);
});
});

View File

@@ -5,13 +5,10 @@ const assert = require("chai").assert;
describe("Create Safari session", function() {
it("should create and destroy IOS Safari session", async function() {
let client = webdriverio.remote(iosOptions);
return client
.init()
.url("https://www.google.com")
.title(function(result) {
assert.equal(result.value, "Google");
})
.end();
let client = await webdriverio.remote(iosOptions);
await client.url("https://www.google.com");
const title = await client.getTitle();
assert.equal(title, "Google");
await client.deleteSession();
});
});