Merge pull request #31756 from MrOggy85/feature/webdriverio-appium

add webdriverio appium desired capabilities
This commit is contained in:
Sheetal Nandi 2019-01-03 09:16:48 -08:00 committed by GitHub
commit 8613c8bbf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 95 additions and 73 deletions

View File

@ -6,6 +6,7 @@
// Tanvir ul Islam <https://github.com/tanvirislam06>
// Dave Parslow <https://github.com/daveparslow>
// Phil Leger <https://github.com/phil-lgr>
// Oskar Lindgren <https://github.com/mroggy85>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
@ -273,6 +274,11 @@ declare namespace WebdriverIO {
[name: string]: any;
};
// Appium specific
platformVersion?: string;
automationName?: string;
app?: string;
cleanSession?: boolean;
// Chrome specific

View File

@ -2,11 +2,18 @@ import * as webdriverio from "webdriverio";
import { assert } from "chai";
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
const { describe, it, before, after, beforeEach, afterEach } = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & { only: any, skip: any };
};
describe("webdriver.io page", () => {
describe("my webdriverio tests", () => {
let client: webdriverio.Client<void>;
before(async () => {
client = webdriverio.remote({ deprecationWarnings: true, desiredCapabilities: { browserName: "phantomjs" } });
await client.init();
});
it("should have the right title - the good old callback way", () => {
assert.equal(
browser
@ -23,15 +30,6 @@ describe("webdriver.io page", () => {
assert.equal(title, "WebdriverIO - Selenium 2.0 javascript bindings for nodejs");
});
});
});
describe.only("my webdriverio tests", () => {
let client: webdriverio.Client<void>;
before(async () => {
client = webdriverio.remote({ deprecationWarnings: true, desiredCapabilities: { browserName: "phantomjs" } });
await client.init();
});
it("Github test", async () => {
await client.url("https://github.com/");
@ -57,76 +55,94 @@ describe.only("my webdriverio tests", () => {
});
});
const matrix = webdriverio.multiremote({
browserA: {
desiredCapabilities: {
browserName: "chrome",
chromeOptions: {
args: [
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream",
]
}
}
},
browserB: {
desiredCapabilities: {
browserName: "chrome",
chromeOptions: {
args: [
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream",
]
}
}
}
describe("multiremote test", () => {
let matrix: webdriverio.Client<void>;
before(async () => {
matrix = webdriverio.multiremote({
browserA: {
desiredCapabilities: {
browserName: "chrome",
chromeOptions: {
args: [
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream",
],
},
},
},
browserB: {
desiredCapabilities: {
browserName: "chrome",
chromeOptions: {
args: [
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream",
],
},
},
},
});
});
const channel = Math.round(Math.random() * 100000000000);
it("clicks a button in a random channel at apprtc", () => {
const channel = Math.round(Math.random() * 100000000000);
matrix
.init()
.url("https://apprtc.appspot.com/r/" + channel)
.click("#confirm-join-button")
.pause(5000)
.end();
matrix
.init()
.url("https://apprtc.appspot.com/r/" + channel)
.click("#confirm-join-button")
.pause(5000)
.end();
});
const options = {
desiredCapabilities: {
browserName: "chrome"
}
};
after(async () => {
await matrix.end();
});
});
webdriverio
.remote(options)
.init()
.url("https://news.ycombinator.com/")
.selectorExecute("//div", (inputs: HTMLElement[], message: string) => {
return `${inputs.length} ${message}`;
}, "divs on the page")
.then((res: string) => {
console.log(res);
})
.end();
describe("testing feaures with chrome", () => {
const options = {
desiredCapabilities: {
browserName: "chrome",
},
};
webdriverio
.remote(options)
.init()
.url("http://www.google.com/")
.waitForVisible("//input[@type='submit']", 5000)
.then((visible) => {
console.log(visible); // Should return true
})
.end();
it("can use selectorExecute", () => {
webdriverio
.remote(options)
.init()
.url("https://news.ycombinator.com/")
.selectorExecute("//div", (inputs: HTMLElement[], message: string) => {
return `${inputs.length} ${message}`;
}, "divs on the page")
.then((res: string) => {
console.log(res);
})
.end();
});
let hooks: webdriverio.Hooks = {};
it("can waitForVisible", () => {
webdriverio
.remote(options)
.init()
.url("http://www.google.com/")
.waitForVisible("//input[@type='submit']", 5000)
.then((visible) => {
console.log(visible); // Should return true
})
.end();
});
});
let hooks: webdriverio.Hooks = {};
hooks = {
// Hooks can be a noop function
onPrepare: () => undefined,
onError() {
// Hooks don't have to return a value
}
// Hooks can be a noop function
onPrepare: () => undefined,
onError() {
// Hooks don't have to return a value
}
};
hooks.onComplete = async () => {