UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

55 lines 3.26 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const sinon_1 = __importDefault(require("sinon")); const driver_1 = require("../../../lib/driver"); const chai_1 = require("chai"); const xmlHeader = '<?xml version="1.0" encoding="UTF-8"?>'; const xmlBody = '<some-xml/>'; const srcTree = `${xmlHeader}${xmlBody}`; describe('source commands', function () { const driver = new driver_1.XCUITestDriver({}); const proxyStub = sinon_1.default.stub(driver, 'proxyCommand').callsFake(async () => srcTree); afterEach(function () { proxyStub.resetHistory(); }); describe('getPageSource', function () { it('should send translated GET request to WDA', async function () { await driver.getPageSource(); (0, chai_1.expect)(proxyStub.calledOnce).to.be.true; (0, chai_1.expect)(proxyStub.firstCall.args[0]).to.eql('/source?format=xml&scope=AppiumAUT'); (0, chai_1.expect)(proxyStub.firstCall.args[1]).to.eql('GET'); }); it('should send translated GET request with null excludedAttributes to WDA', async function () { await driver.updateSettings({ 'pageSourceExcludedAttributes': null }); await driver.getPageSource(); (0, chai_1.expect)(proxyStub.calledOnce).to.be.true; (0, chai_1.expect)(proxyStub.firstCall.args[0]).to.eql('/source?format=xml&scope=AppiumAUT'); (0, chai_1.expect)(proxyStub.firstCall.args[1]).to.eql('GET'); }); it('should send translated GET request with empty excludedAttributes to WDA', async function () { await driver.updateSettings({ 'pageSourceExcludedAttributes': '' }); await driver.getPageSource(); (0, chai_1.expect)(proxyStub.calledOnce).to.be.true; (0, chai_1.expect)(proxyStub.firstCall.args[0]).to.eql('/source?format=xml&scope=AppiumAUT'); (0, chai_1.expect)(proxyStub.firstCall.args[1]).to.eql('GET'); }); it('should send translated GET request with single excludedAttributes to WDA', async function () { await driver.updateSettings({ 'pageSourceExcludedAttributes': 'visible' }); await driver.getPageSource(); (0, chai_1.expect)(proxyStub.calledOnce).to.be.true; (0, chai_1.expect)(proxyStub.firstCall.args[0]).to.eql('/source?format=xml&scope=AppiumAUT&excluded_attributes=visible'); (0, chai_1.expect)(proxyStub.firstCall.args[1]).to.eql('GET'); }); it('should send translated GET request with multiple excludedAttributes to WDA', async function () { await driver.updateSettings({ 'pageSourceExcludedAttributes': 'visible,accessible' }); await driver.getPageSource(); (0, chai_1.expect)(proxyStub.calledOnce).to.be.true; (0, chai_1.expect)(proxyStub.firstCall.args[0]).to.eql('/source?format=xml&scope=AppiumAUT&excluded_attributes=visible%2Caccessible'); (0, chai_1.expect)(proxyStub.firstCall.args[1]).to.eql('GET'); }); }); }); //# sourceMappingURL=source-specs.js.map