appium.old/test/helpers.js

36 строки
1.0 KiB
JavaScript
Исходник Постоянная ссылка Обычный вид История

import path from 'path';
import wd from 'wd';
import B from 'bluebird';
W3C Full Implementation (#9972) * Refactored code from createSession into parseCapsForInnerDriver() * parseCapsForInnerDriver() takes jsonwp and w3c capabilities and translates them into objects that can be accepted by the "inner driver" that it proxies to * It adds defaultCapabilities to capabilities.firstMatch and jsonwp caps * It finds matching caps for W3C and then creates a new W3C capabilities object that only has the valid matching one * After parseCapsForInnerDriver() parses the JSONWP and W3C it passes the results along to the inner-driver and it's up to the inner driver to create a W3C or JSONWP session * Add validation to W3C session creation * Call to 'processCapabilities' does validation now so that it will match an object that passes Appium's validation rules (e.g.: platformName, deviceName required; automation name must be valid, etc...) * Test that it accepts combo of W3C and JSONWP capabilities * Test that it rejects invalid W3C capabilities with 400 error * Also added 'createSession' unit test * Stripped out unnecessary async/await from driver-specs * Insert Appium prefixes into W3C caps * Previously, Appium just took the W3C capabilities, processed them into a caps object and passed them into the inner driver as ``` { alwaysMatch: parsedCaps, firstMatch: [{}], } ``` * The problem with this is that all of the parsedCaps were unprefixed, and therefore the Inner Driver complained about it * Now, it takes the parsedCaps and calls a new method called 'insertAppiumPrefixes' on the parsed caps like this: ``` { alwaysMatch: {...insertAppiumPrefixes(parsedCaps)}, firstMatch: [{}], } ``` * Refactored tests that were affected by this change * Added tests to test insertAppiumPrefixes function
2018-01-16 21:26:44 +03:00
import {insertAppiumPrefixes} from '../lib/utils';
const TEST_HOST = 'localhost';
const TEST_PORT = 4723;
const TEST_FAKE_APP = path.resolve(__dirname, "..", "..", "node_modules",
"appium-fake-driver", "test", "fixtures",
"app.xml");
function initSession (caps) {
let resolve = () => {};
let driver;
before(async function () {
driver = wd.promiseChainRemote({host: TEST_HOST, port: TEST_PORT});
resolve(driver);
await driver.init(caps);
});
after(async function () {
await driver.quit();
});
return new B((_resolve) => {
resolve = _resolve;
});
}
W3C Full Implementation (#9972) * Refactored code from createSession into parseCapsForInnerDriver() * parseCapsForInnerDriver() takes jsonwp and w3c capabilities and translates them into objects that can be accepted by the "inner driver" that it proxies to * It adds defaultCapabilities to capabilities.firstMatch and jsonwp caps * It finds matching caps for W3C and then creates a new W3C capabilities object that only has the valid matching one * After parseCapsForInnerDriver() parses the JSONWP and W3C it passes the results along to the inner-driver and it's up to the inner driver to create a W3C or JSONWP session * Add validation to W3C session creation * Call to 'processCapabilities' does validation now so that it will match an object that passes Appium's validation rules (e.g.: platformName, deviceName required; automation name must be valid, etc...) * Test that it accepts combo of W3C and JSONWP capabilities * Test that it rejects invalid W3C capabilities with 400 error * Also added 'createSession' unit test * Stripped out unnecessary async/await from driver-specs * Insert Appium prefixes into W3C caps * Previously, Appium just took the W3C capabilities, processed them into a caps object and passed them into the inner driver as ``` { alwaysMatch: parsedCaps, firstMatch: [{}], } ``` * The problem with this is that all of the parsedCaps were unprefixed, and therefore the Inner Driver complained about it * Now, it takes the parsedCaps and calls a new method called 'insertAppiumPrefixes' on the parsed caps like this: ``` { alwaysMatch: {...insertAppiumPrefixes(parsedCaps)}, firstMatch: [{}], } ``` * Refactored tests that were affected by this change * Added tests to test insertAppiumPrefixes function
2018-01-16 21:26:44 +03:00
const BASE_CAPS = {platformName: 'Fake', deviceName: 'Fake', app: TEST_FAKE_APP};
const W3C_PREFIXED_CAPS = {...insertAppiumPrefixes(BASE_CAPS)};
const W3C_CAPS = {
2018-10-03 16:39:25 +03:00
alwaysMatch: {...W3C_PREFIXED_CAPS},
W3C Full Implementation (#9972) * Refactored code from createSession into parseCapsForInnerDriver() * parseCapsForInnerDriver() takes jsonwp and w3c capabilities and translates them into objects that can be accepted by the "inner driver" that it proxies to * It adds defaultCapabilities to capabilities.firstMatch and jsonwp caps * It finds matching caps for W3C and then creates a new W3C capabilities object that only has the valid matching one * After parseCapsForInnerDriver() parses the JSONWP and W3C it passes the results along to the inner-driver and it's up to the inner driver to create a W3C or JSONWP session * Add validation to W3C session creation * Call to 'processCapabilities' does validation now so that it will match an object that passes Appium's validation rules (e.g.: platformName, deviceName required; automation name must be valid, etc...) * Test that it accepts combo of W3C and JSONWP capabilities * Test that it rejects invalid W3C capabilities with 400 error * Also added 'createSession' unit test * Stripped out unnecessary async/await from driver-specs * Insert Appium prefixes into W3C caps * Previously, Appium just took the W3C capabilities, processed them into a caps object and passed them into the inner driver as ``` { alwaysMatch: parsedCaps, firstMatch: [{}], } ``` * The problem with this is that all of the parsedCaps were unprefixed, and therefore the Inner Driver complained about it * Now, it takes the parsedCaps and calls a new method called 'insertAppiumPrefixes' on the parsed caps like this: ``` { alwaysMatch: {...insertAppiumPrefixes(parsedCaps)}, firstMatch: [{}], } ``` * Refactored tests that were affected by this change * Added tests to test insertAppiumPrefixes function
2018-01-16 21:26:44 +03:00
firstMatch: [{}],
};
export { initSession, TEST_FAKE_APP, TEST_HOST, TEST_PORT, BASE_CAPS, W3C_PREFIXED_CAPS, W3C_CAPS };