fix(universal-xml): remove code related to proxying now that it is moot
MODIFY
packages/appium-plugins/packages/universal-xml/lib/plugin.js
packages/appium-plugins/packages/universal-xml/lib/plugin.js
@@ -6,21 +6,13 @@ import { transformSourceXml } from './source';
import { transformQuery } from './xpath';
import log from './logger';
-const SOURCE_URL_RE = new RegExp('/session/[^/]+/source');
-
export default class UniversalXMLPlugin extends BasePlugin {
commands = ['getPageSource', 'findElement', 'findElements', 'findElementFromElement',
'findElementsFromElement'];
- // we don't want the UIA2 driver to proxy source requests directly to the UIA2 server, since we
- // want to handle the source command ourselves
- shouldAvoidProxy (method, route) {
- return method === 'GET' && SOURCE_URL_RE.test(route);
- }
-
async getPageSource (next, driver, sessId, addIndexPath = false) {
- const source = await driver.getPageSource();
+ const source = next ? await next() : await driver.getPageSource();
const metadata = {};
const {platformName} = driver.caps;
if (platformName.toLowerCase() === 'android') {

MODIFY
packages/appium-plugins/packages/universal-xml/test/unit/plugin-specs.js
packages/appium-plugins/packages/universal-xml/test/unit/plugin-specs.js
@@ -9,17 +9,17 @@ chai.use(chaiAsPromised);
chai.should();
describe('UniversalXMLPlugin', function () {
- const next = () => true;
+ let next;
const p = new UniversalXMLPlugin();
describe('getPageSource', function () {
const driver = new BaseDriver();
it('should transform page source for ios', async function () {
- driver.getPageSource = () => XML_IOS;
+ next = driver.getPageSource = () => XML_IOS;
driver.caps = {platformName: 'iOS'};
await p.getPageSource(next, driver).should.eventually.eql(XML_IOS_TRANSFORMED);
});
it('should transform page source for android', async function () {
- driver.getPageSource = () => XML_ANDROID;
+ next = driver.getPageSourcce = () => XML_ANDROID;
driver.caps = {platformName: 'Android'};
driver.opts = {appPackage: 'io.cloudgrey.the_app'};
await p.getPageSource(next, driver).should.eventually.eql(XML_ANDROID_TRANSFORMED);
@@ -29,7 +29,7 @@ describe('UniversalXMLPlugin', function () {
describe('findElement(s)', function () {
const driver = new BaseDriver();
it('should turn an xpath query into another query run on the original ios source', async function () {
- driver.getPageSource = () => XML_IOS;
+ next = driver.getPageSource = () => XML_IOS;
driver.caps = {platformName: 'iOS'};
// mock out the findElement function to just return an xml node from the fixture
driver.findElement = (strategy, selector) => {
@@ -42,7 +42,7 @@ describe('UniversalXMLPlugin', function () {
});
it('should turn an xpath query into another query run on the original android source', async function () {
- driver.getPageSource = () => XML_ANDROID;
+ next = driver.getPageSource = () => XML_ANDROID;
driver.caps = {platformName: 'Android'};
driver.opts = {appPackage: 'io.cloudgrey.the_app'};
driver.findElement = (strategy, selector) => {

fix(universal-xml): remove code related to proxying now that it is moot