Created
March 11, 2021 19:02
-
-
Save DigiTec/47205ed17ddda735503b9ad80b34e176 to your computer and use it in GitHub Desktop.
Sample VR WebDriver Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const parseArgs = require('./parseArgs'); | |
const options = parseArgs(process.argv); | |
const host = options.host || process.env.SHELLDRIVER_HOST || '127.0.0.1'; | |
const port = options.port || process.env.SHELLDRIVER_PORT || '8080'; | |
const overlayPort = options.overlayPort || process.env.SHELLDRIVER_OVERLAY_PORT || '8081'; | |
const shellDriverFactory = require('./shell-driver/shell-driver'); | |
const shellDriver = new shellDriverFactory.ShellDriver(host, port); | |
const shellDriverOverlay = new shellDriverFactory.ShellDriver(host, overlayPort); | |
// TODO: Add the ability to grep the directory via a --test-files | |
// TODO: Add the ability to filter the tests via a --test-filter | |
// CONSIDER: Adding some sort of tagging facility to the test framework. | |
const testEntries = []; | |
for (let testArg of options.unnamedArgs) { | |
testArg = testArg.replace('\\', '/'); | |
const newTests = require(testArg); | |
testEntries.splice(-1, 0, ...newTests.Tests); | |
} | |
// TODO: Build an a better assert and logging framework. | |
function assert(condition, message) { | |
if (!condition) { | |
throw new Error(message || "fail"); | |
} | |
} | |
async function runTests(testEntries) { | |
const verbose = !!options.verbose; | |
for (let test of testEntries) { | |
console.log(`Executing test ${test.prototype.constructor.name}...`); | |
try { | |
const result = await test.runTest({shellDriver, shellDriverOverlay, assert, verbose}); | |
if (result === undefined) { | |
console.log(` Test passed without exception`); | |
} else { | |
console.log(` Test passed without exception and returned ${result}`); | |
} | |
} catch (exc) { | |
console.log(` Test failed with exception ${exc.message} and stack ${exc.stack}`); | |
} | |
} | |
} | |
runTests(testEntries); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestTaskbarVisibility { | |
static async runTest(config) { | |
// Lift out all of the test fixtures needed by this test. | |
const shellDriver = config.shellDriver; | |
const assert = config.assert; | |
const systemTaskBar = await shellDriver.getSystemTaskBar(); | |
let isTaskbarVisible = false; | |
for (const layer of systemTaskBar.layers) { | |
if (layer.name === '#main' && layer.visible === true) { | |
isTaskbarVisible = true; | |
break; | |
} | |
} | |
assert(isTaskbarVisible === true, "Verify Taskbar is visible."); | |
} | |
} | |
module.exports.Tests = [ TestTaskbarVisibility ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment