unknown command: session/0560573d012ab858001aaea2ae11fcb0/window/rect
@APshenkin @DavertMik : Please help me in this
# paste output here
Provide test source code if related
js:
// paste test
```js
{
"output": "./output",
"helpers": {
"WebDriverIO": {
"url": "https://formsviewertest.azurewebsites.net",
"browser": "chrome",
"windowSize": "maximize",
"restart": false,
"keepBrowserState": true,
"keepCookies": true
},
"TabSwitch": {
"require": "./tabswitch_helper.js"
}
},
"include": {
"I": "./steps_file.js",
"loginPagePage": "./pages/loginPage.js",
"manageCredentialPage": "./pages/manageCredential.js",
"templatePage": "./pages/template.js",
"uiHelper": "./pages/uiHelper.js",
"fvAssert": "./pages/fvAssert.js",
"listPage": "./pages/listPage.js",
"fvData": "./InputData/login.js"
},
"mocha": {
"reporterOptions": {
"codeceptjs-cli-reporter": {
"stdout": "-",
"options": {
"verbose": false,
"steps": true
}
},
"mocha-junit-reporter": {
"stdout": "./output/console.log",
"options": {
"mochaFile": "./output/result.xml"
}
}
}
},
"bootstrap": "./config/start_server.js",
"teardown": "./config/stop_server.js",
"hooks": [],
"tests": "*/fv__test.js",
"timeout": 10000,
"name": "FV"
}
I have found that sometimes the versions of the selenium-standalone have caused my tests to fail. So I would check if you have recently upgraded the selenium-standalone package or if you're starting the selenium server manually, any of the drivers or selenium server version (i.e. 3.4 to 3.5)
At the moment I use npm install -g [email protected] for my tests. This was the last version that still uses selenium 3.4.
@reubenmiller : I am using selenium-server-standalone-3.8.1.jar on my local machine and getting the same error and yes I am starting selenium server manually.
on my client server I am using selenium-server-standalone-3.6.0.jar and starting selenium server manually and getting this[error : unknown command: session/0560573d012ab858001aaea2ae11fcb0/window/rect] there also
Ok, I think this is a bug with the resizeWindow function in the WebDriverIO Helper in codeceptjs. I have done a test on my machine and it looks ok. Though can you quickly test it out on your machine to see if it solves your problem?
./node_modules/codeceptjs/lib/helper/WebDriverIO.jsasync resizeWindow/**
* {{> ../webapi/resizeWindow }}
* Appium: not tested in web, in apps doesn't work
*/
async resizeWindow(width, height) {
if (width !== 'maximize') {
return this.browser.windowHandleSize({ width, height });
}
const { screenWidth, screenHeight } = await this.browser.execute(() => ({
screenHeight: window.screen.height,
screenWidth: window.screen.width,
})).then(res => res.value);
return this.browser.windowHandleSize({ width: screenWidth, height: screenHeight });
}
Let me know if you have any luck. If it solves it then I will submit a PR.
@reubenmiller : I did this but I am getting the same error.I am just pasting below the webdriverIO file after edit that you ask me to do.
let webdriverio;
const requireg = require('requireg');
const Helper = require('../helper');
const stringIncludes = require('../assert/include').includes;
const { urlEquals, equals } = require('../assert/equal');
const empty = require('../assert/empty').empty;
const truth = require('../assert/truth').truth;
const {
xpathLocator, fileExists, clearString, decodeUrl, chunkArray,
} = require('../utils');
const ElementNotFound = require('./errors/ElementNotFound');
const assert = require('assert');
const path = require('path');
const webRoot = 'body';
const Locator = require('../locator');
let withinStore = {};
/**
url - base url of website to be testedbrowser - browser in which perform testingrestart (optional, default: true) - restart browser between tests.smartWait: (optional) enables SmartWait; wait for additional milliseconds for element to appear. Enable for 5 secs: "smartWait": 5000disableScreenshots (optional, default: false) - don't save screenshot on failureuniqueScreenshotNames (optional, default: false) - option to prevent screenshot override if you have scenarios with the same name in different suiteskeepBrowserState (optional, default: false) - keep browser state between tests when restart set to false.keepCookies (optional, default: false) - keep cookies between tests when restart set to false.windowSize: (optional) default window size. Set to maximize or a dimension in the format 640x480.waitForTimeout: (option) sets default wait time in ms for all wait* functions. 1000 by default;desiredCapabilities: Selenium's [desiredmanualStart (optional, default: false) - do not start browser before a test, start it manually inside a helperthis.helpers["WebDriverIO"]._startBrowser()timeouts: WebDriverIO timeouts defined as hash.helpers.WebDriverIO.desiredCapabilities.proxy key.Sauce Labs BrowserStack TestingBotBrowserStack and Sauce Labs is simple. All you need to douser and key parameters. WebDriverIO automatically know whichbrowser property:this.options = {
smartWait: 0,
waitForTimeout: 1000, // ms
desiredCapabilities: {},
restart: true,
uniqueScreenshotNames: false,
disableScreenshots: false,
fullPageScreenshots: true,
manualStart: false,
keepCookies: false,
keepBrowserState: false,
deprecationWarnings: false,
timeouts: {
script: 1000, // ms
},
};
this._validateConfig(config);
}
_validateConfig(config) {
// set defaults
this.root = webRoot;
this.isRunning = false;
// override defaults with config
Object.assign(this.options, config);
this.options.baseUrl = this.options.url || this.options.baseUrl;
this.options.desiredCapabilities.browserName = this.options.browser || this.options.desiredCapabilities.browserName;
this.options.waitForTimeout /= 1000; // convert to seconds
if (!this.options.desiredCapabilities.platformName && (!this.options.url || !this.options.browser)) {
throw new Error(`
WebDriverIO requires at url and browser to be set.
Check your codeceptjs config file to ensure these are set properly
{
"helpers": {
"WebDriverIO": {
"url": "YOUR_HOST"
"browser": "YOUR_PREFERRED_TESTING_BROWSER"
}
}
}
`);
}
}
static _checkRequirements() {
try {
requireg('webdriverio');
} catch (e) {
return ['webdriverio'];
}
}
static _config() {
return [{
name: 'url',
message: 'Base url of site to be tested',
default: 'http://localhost',
}, {
name: 'browser',
message: 'Browser in which testing will be performed',
default: 'chrome',
}];
}
_beforeSuite() {
if (!this.options.restart && !this.options.manualStart && !this.isRunning) {
this.debugSection('Session', 'Starting singleton browser session');
return this._startBrowser();
}
}
async _startBrowser() {
if (this.options.multiremote) {
this.browser = webdriverio.multiremote(this.options.multiremote).init();
} else {
this.browser = webdriverio.remote(this.options).init();
}
await this.browser;
this.isRunning = true;
if (this.options.timeouts) {
await this.defineTimeout(this.options.timeouts);
}
if (this.options.windowSize === 'maximize') {
await this.resizeWindow('maximize');
} else if (this.options.windowSize && this.options.windowSize.indexOf('x') > 0) {
const dimensions = this.options.windowSize.split('x');
await this.resizeWindow(dimensions[0], dimensions[1]);
}
return this.browser;
}
async _before() {
this.context = this.root;
if (this.options.restart && !this.options.manualStart) return this._startBrowser();
if (!this.isRunning && !this.options.manualStart) return this._startBrowser();
return this.browser;
}
async _after() {
if (!this.isRunning) return;
if (this.options.restart) {
this.isRunning = false;
return this.browser.end();
}
if (this.options.keepBrowserState) return;
if (!this.options.keepCookies && this.options.desiredCapabilities.browserName) {
this.debugSection('Session', 'cleaning cookies and localStorage');
await this.browser.deleteCookie();
}
await this.browser.execute('localStorage.clear();').catch((err) => {
if (!(err.message.indexOf("Storage is disabled inside 'data:' URLs.") > -1)) throw err;
});
await this.closeOtherTabs();
return this.browser;
}
_afterSuite() {
}
_finishTest() {
if (!this.options.restart && this.isRunning) return this.browser.end();
}
async _failed(test) {
if (Object.keys(withinStore).length !== 0) await this._withinEnd();
if (!this.options.disableScreenshots) {
let fileName = clearString(test.title);
if (test.ctx && test.ctx.test && test.ctx.test.type === 'hook') fileName = clearString(${test.title}_${test.ctx.test.title});
if (this.options.uniqueScreenshotNames) {
const uuid = test.uuid || test.ctx.test.uuid;
fileName = ${fileName.substring(0, 10)}_${uuid}.failed.png;
} else {
fileName += '.failed.png';
}
await this.saveScreenshot(fileName, this.options.fullPageScreenshots).catch((err) => {
if (err &&
err.type &&
err.type === 'RuntimeError' &&
err.message &&
(err.message.indexOf('was terminated due to') > -1 || err.message.indexOf('no such window: target window already closed') > -1)
) {
this.isRunning = false;
}
});
}
}
async _withinBegin(locator) {
const frame = isFrameLocator(locator);
const client = this.browser;
if (frame) {
if (Array.isArray(frame)) {
withinStore.frame = frame.join('>');
return client
.frame(null)
.then(() => frame.reduce((p, frameLocator) => p.then(() => this.switchTo(frameLocator)), Promise.resolve()));
}
withinStore.frame = frame;
return this.switchTo(frame);
}
withinStore.elFn = this.browser.element;
withinStore.elsFn = this.browser.elements;
this.context = locator;
const res = await client.element(withStrictLocator.call(this, locator));
this.browser.element = function (l) {
return this.elementIdElement(res.value.ELEMENT, l);
};
this.browser.elements = function (l) {
return this.elementIdElements(res.value.ELEMENT, l);
};
return this.browser;
}
async _withinEnd() {
if (withinStore.frame) {
withinStore = {};
return this.switchTo(null);
}
this.context = this.root;
this.browser.element = withinStore.elFn;
this.browser.elements = withinStore.elsFn;
withinStore = {};
}
/**
*/
async _locate(locator, smartWait = false) {
if (!this.options.smartWait || !smartWait) return this.browser.elements(withStrictLocator.call(this, locator));
this.debugSection(SmartWait (${this.options.smartWait}ms),Locating ${locator} in ${this.options.smartWait}`);await this.defineTimeout({ implicit: this.options.smartWait });
const els = await this.browser.elements(withStrictLocator.call(this, locator));
await this.defineTimeout({ implicit: 0 });
return els;
}
/**
/**
/**
/**
/**
/**
const res = await findClickable.call(this, locator, locateFn);
if (context) {
assertElementExists(res, locator, 'Clickable element', `was not found inside element ${new Locator(context).toString()}`);
} else {
assertElementExists(res, locator, 'Clickable element');
}
return this.browser[clickMethod](res.value[0].ELEMENT);
}
/**
const res = await findClickable.call(this, locator, locateFn);
if (context) {
assertElementExists(res, locator, 'Clickable element', `was not found inside element ${new Locator(context).toString()}`);
} else {
assertElementExists(res, locator, 'Clickable element');
}
const elem = res.value[0];
return this.browser.moveTo(elem.ELEMENT).doDoubleClick();
}
/**
const res = await this._locate(locator, true);
assertElementExists(res, locator, 'Clickable element');
const elem = res.value[0];
if (this.browser.isMobile) return this.browser.touchClick(elem.ELEMENT);
return this.browser.moveTo(elem.ELEMENT).buttonPress('right');
}
/**
/**
/**
/**
if (!Array.isArray(option)) {
option = [option];
}
// select options by visible text
option.forEach(opt => commands.push(this.browser.elementIdElements(elem.ELEMENT, Locator.select.byVisibleText(xpathLocator.literal(opt)))));
let els = await this.browser.unify(commands, { extractValue: true });
commands = [];
const clickOptionFn = (el) => {
if (el[0]) el = el[0];
if (el && el.ELEMENT) commands.push(this.browser.elementIdClick(el.ELEMENT));
};
if (els.length) {
els.forEach(clickOptionFn);
return this.browser.unify(commands);
}
// select options by value
option.forEach(opt => commands.push(this.browser.elementIdElements(elem.ELEMENT, Locator.select.byValue(xpathLocator.literal(opt)))));
els = await this.browser.unify(commands, { extractValue: true });
if (els.length === 0) {
throw new ElementNotFound(select, `Option ${option} in`, 'was found neither by visible text not by value');
}
commands = [];
els.forEach(clickOptionFn);
return this.browser.unify(commands);
}
/**
File at ${file} can not be found on local system);Uploading ${file});const res = await this.browser.uploadFile(file);
assertElementExists(el, locator, 'File field');
return this.browser.elementIdValue(el.value[0].ELEMENT, res.value);
}
/**
const res = await findCheckable.call(this, field, locateFn);
assertElementExists(res, field, 'Checkable');
const elem = res.value[0];
const isSelected = await this.browser.elementIdSelected(elem.ELEMENT);
if (isSelected.value) return Promise.resolve(true);
return this.browser[clickMethod](elem.ELEMENT);
}
/**
const res = await findCheckable.call(this, field, locateFn);
assertElementExists(res, field, 'Checkable');
const elem = res.value[0];
const isSelected = await this.browser.elementIdSelected(elem.ELEMENT);
if (!isSelected.value) return Promise.resolve(true);
return this.browser[clickMethod](elem.ELEMENT);
}
/**
const commands = [];
res.value.forEach(el => commands.push(this.browser.elementIdText(el.ELEMENT)));
return this.browser.unify(commands, {
extractValue: true,
}).then(selected => selected);
}
/**
yield operator./**
const commands = [];
res.value.forEach(el => commands.push(this.browser.elementIdAttribute(el.ELEMENT, 'value')));
return this.browser.unify(commands, {
extractValue: true,
}).then(selected => selected);
}
/**
const commands = [];
res.value.forEach(el => commands.push(this.browser.elementIdCssProperty(el.ELEMENT, cssProperty)));
return this.browser.unify(commands, {
extractValue: true,
}).then(selected => selected);
}
/**
/**
/**
*/
async seeTitleEquals(text) {
const title = await this.browser.getTitle();
return assert.equal(title, text,expected web page title to be ${text}, but found ${title}`);/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
elements of ${locator}, 'to be seen').assert(false);elements of ${locator}, 'to be seen').assert(selected);/**
elements of ${locator}, 'to be seen').negate(false);elements of ${locator}, 'to be seen').negate(selected);/**
/**
/**
/**
/**
/**
Current URL is [${url}]);/**
/**
*/
async seeNumberOfElements(selector, num) {
const res = await this._locate(withStrictLocator.call(this, selector));
return assert.equal(res.value.length, num,expected number of elements (${selector}) is ${num}, but found ${res.value.length}`);/**
*/
async seeNumberOfVisibleElements(locator, num) {
const res = await this.grabNumberOfVisibleElements(locator);
return assert.equal(res, num,expected number of visible elements (${locator}) is ${num}, but found ${res}`);/**
*/
async seeCssPropertiesOnElements(locator, cssProperties) {
const res = await this._locate(locator);
assertElementExists(res, locator);
const elemAmount = res.value.length;
const commands = [];
res.value.forEach((el) => {
Object.keys(cssProperties).forEach((prop) => {
commands.push(this.browser.elementIdCssProperty(el.ELEMENT, prop));
});
});
let props = await this.browser.unify(commands, { extractValue: true });
const values = Object.keys(cssProperties).map(key => cssProperties[key]);
if (!Array.isArray(props)) props = [props];
let chunked = chunkArray(props, values.length);
chunked = chunked.filter((val) => {
for (let i = 0; i < val.length; ++i) {
if (val[i] !== values[i]) return false;
}
return true;
});
return assert.ok(
chunked.length === elemAmount,
Not all elements (${locator}) have CSS property ${JSON.stringify(cssProperties)}`,/**
*/
async seeAttributesOnElements(locator, attributes) {
const res = await this._locate(locator);
assertElementExists(res, locator);
const elemAmount = res.value.length;
const commands = [];
res.value.forEach((el) => {
Object.keys(attributes).forEach((attr) => {
commands.push(this.browser.elementIdAttribute(el.ELEMENT, attr));
});
});
let attrs = await this.browser.unify(commands, { extractValue: true });
const values = Object.keys(attributes).map(key => attributes[key]);
if (!Array.isArray(attrs)) attrs = [attrs];
let chunked = chunkArray(attrs, values.length);
chunked = chunked.filter((val) => {
for (let i = 0; i < val.length; ++i) {
if (val[i] !== values[i]) return false;
}
return true;
});
return assert.ok(
chunked.length === elemAmount,
Not all elements (${locator}) have attributes ${JSON.stringify(attributes)}`,/**
const commands = [];
res.value.forEach(el => commands.push(this.browser.elementIdDisplayed(el.ELEMENT)));
let selected = await this.browser.unify(commands, { extractValue: true });
if (!Array.isArray(selected)) selected = [selected];
selected = selected.filter(val => val === true);
return selected.length;
}
/**
/**
/**
/**
/**
/**
/**
if (locator) {
const res = await this._locate(withStrictLocator.call(this, locator), true);
if (!res.value || res.value.length === 0) {
return truth(`elements of ${locator}`, 'to be seen').assert(false);
}
const elem = res.value[0];
if (this.browser.isMobile) return this.browser.touchScroll(elem.ELEMENT, offsetX, offsetY);
const location = await this.browser.elementIdLocation(elem.ELEMENT);
assertElementExists(location, 'Failed to receive', 'location');
return this.browser.execute((x, y) => window.scrollTo(x, y), location.value.x + offsetX, location.value.y + offsetY);
}
if (this.browser.isMobile) return this.browser.touchScroll(locator, offsetX, offsetY);
return this.browser.execute((x, y) => window.scrollTo(x, y), offsetX, offsetY);
}
/**
const res = await this._locate(withStrictLocator.call(this, locator), true);
assertElementExists(res, locator);
const elem = res.value[0];
if (!this.browser.isMobile) {
return this.browser.moveTo(elem.ELEMENT, offsetX, offsetY);
}
const size = await this.browser.elementIdSize(elem.ELEMENT);
assertElementExists(size, 'Failed to receive', 'size');
const location = await this.browser.elementIdLocation(elem.ELEMENT);
assertElementExists(size, 'Failed to receive', 'location');
let x = location.value.x + size.value.width / 2;
let y = location.value.y + size.value.height / 2;
if (hasOffsetParams) {
x = location.value.x + offsetX;
y = location.value.y + offsetY;
}
return this.browser.touchMove(x, y);
}
/**
if (!fullPage) {
this.debug(`Screenshot has been saved to ${outputFile}`);
return this.browser.saveScreenshot(outputFile);
}
const { width, height } = await this.browser.execute(() => ({
height: document.body.scrollHeight,
width: document.body.scrollWidth,
}));
await this.browser.windowHandleSize(width, height);
this.debug(`Screenshot has been saved to ${outputFile}`);
return this.browser.saveScreenshot(outputFile);
}
/**
/**
/**
cookie ${name}, 'to be set').assert(res);/**
cookie ${name}, 'to be set').negate(res);/**
/**
/**
/**
window.alert|window.confirm|window.prompt, contains the/**
/**
/**
const { screenWidth, screenHeight } = await this.browser.execute(() => ({
screenHeight: window.screen.height,
screenWidth: window.screen.width,
})).then(res => res.value);
return this.browser.windowHandleSize({ width: screenWidth, height: screenHeight });
}
const { screenWidth, screenHeight } = await this.browser.execute(() => ({
height: window.screen.height,
width: window.screen.width,
}));
return this.browser.windowHandleSize(screenWidth, screenHeight);
}
/**
if (client.isMobile) {
let res = await this._locate(withStrictLocator.call(this, srcElement), true);
assertElementExists(res, srcElement);
let elem = res.value[0];
let location = await this.browser.elementIdLocation(elem.ELEMENT);
assertElementExists(location, `Failed to receive (${srcElement}) location`);
res = await this.browser.touchDown(location.value.x, location.value.y);
if (res.state !== 'success') throw new Error(`Failed to touch button down on (${srcElement})`);
res = await this._locate(withStrictLocator.call(this, destElement), true);
assertElementExists(res, destElement);
elem = res.value[0];
location = await this.browser.elementIdLocation(elem.ELEMENT);
assertElementExists(location, `Failed to receive (${destElement}) location`);
res = await this.browser.touchMove(location.value.x, location.value.y);
if (res.state !== 'success') throw new Error(`Failed to touch move to (${destElement})`);
return this.browser.touchUp(location.value.x, location.value.y);
}
let res = await this.moveCursorTo(withStrictLocator.call(this, srcElement));
if (res.state !== 'success') throw new Error(`Unable to move cursor to (${srcElement})`);
res = await this.browser.buttonDown();
if (res.state !== 'success') throw new Error(`Failed to press button down on (${srcElement})`);
res = await this.moveCursorTo(withStrictLocator.call(this, destElement));
if (res.state !== 'success') throw new Error(`Unable to move cursor to (${destElement})`);
return this.browser.buttonUp();
}
/**
/**
/**
element (${locator}) still not enabled after ${aSec} sec);/**
element (${locator}) still not present on page after ${aSec} sec);/**
/**
*/
async waitInUrl(urlPart, sec = null) {
const client = this.browser;
const aSec = sec || this.options.waitForTimeout;
let currUrl = '';
return client
.waitUntil(function () {
return this.url().then((res) => {
currUrl = decodeUrl(res.value);
return currUrl.indexOf(urlPart) > -1;
});
}, aSec * 1000).catch((e) => {
if (e.type === 'WaitUntilTimeoutError') {
throw new Error(expected url to include ${urlPart}, but found ${currUrl}`);/**
*/
async waitUrlEquals(urlPart, sec = null) {
const aSec = sec || this.options.waitForTimeout;
const baseUrl = this.options.url;
if (urlPart.indexOf('http') < 0) {
urlPart = baseUrl + urlPart;
}
let currUrl = '';
return this.browser.waitUntil(function () {
return this.url().then((res) => {
currUrl = decodeUrl(res.value);
return currUrl === urlPart;
});
}, aSec * 1000).catch((e) => {
if (e.type === 'WaitUntilTimeoutError') {
throw new Error(expected url to be ${urlPart}, but found ${currUrl}`);/**
element (${context}) is not in DOM or there is no element(${context}) with text "${text}" after ${aSec} sec,/**
const selected = await this.browser.unify(commands, { extractValue: true });
if (Array.isArray(selected)) {
return selected.filter(part => part.indexOf(value) >= 0).length > 0;
}
return selected.indexOf(value) >= 0;
}, aSec * 1000,
`element (${field}) is not in DOM or there is no element(${field}) with value "${value}" after ${aSec} sec`,
);
}
/**
const selected = await this.browser.unify(commands, { extractValue: true });
if (Array.isArray(selected)) {
return selected.filter(val => val === true).length > 0;
}
return selected;
}, aSec * 1000, `element (${locator}) still not visible after ${aSec} sec`);
}
/**
res.value.forEach(el => commands.push(this.browser.elementIdDisplayed(el.ELEMENT)));
let selected = await this.browser.unify(commands, { extractValue: true });
if (!Array.isArray(selected)) selected = [selected];
return selected.length === num;
}, aSec * 1000, `The number of elements ${locator} is not ${num} after ${aSec} sec`);
}
/**
const selected = await this.browser.unify(commands, { extractValue: true });
if (Array.isArray(selected)) {
return selected.filter(val => val === false).length > 0;
}
return !selected;
}, aSec * 1000, `element (${locator}) still visible after ${aSec} sec`);
}
/**
/**
element (${locator}) still attached to the DOM after ${aSec} sec);/**
/**
/**
*/
async switchToNextTab(num = 1, sec = null) {
const aSec = sec || this.options.waitForTimeout;
const client = this.browser;
return client
.waitUntil(function () {
return this.getTabIds().then(function (handles) {
return this.getCurrentTabId().then(function (current) {
if (handles.indexOf(current) + num + 1 <= handles.length) {
return this.switchTab(handles[handles.indexOf(current) + num]);
} return false;
});
});
}, aSec * 1000,There is no ability to switch to next tab with offset ${num}`);/**
*/
async switchToPreviousTab(num = 1, sec = null) {
const aSec = sec || this.options.waitForTimeout;
const client = this.browser;
return client
.waitUntil(function () {
return this.getTabIds().then(function (handles) {
return this.getCurrentTabId().then(function (current) {
if (handles.indexOf(current) - num > -1) return this.switchTab(handles[handles.indexOf(current) - num]);
return false;
});
});
}, aSec * 1000,There is no ability to switch to previous tab with offset ${num}`);/**
/**
/**
/**
/**
/**
/**
/**
async function proceedSee(assertType, text, context, strict = false) {
let description;
if (!context) {
if (this.context === webRoot) {
context = this.context;
description = 'web page';
} else {
description = current context ${this.context};
context = './/*';
}
} else {
description = element ${context};
}
const smartWaitEnabled = assertType === 'assert';
const res = await this._locate(withStrictLocator.call(this, context), smartWaitEnabled);
if (!res.value || res.value.length === 0) throw new ElementNotFound(context);
const commands = [];
res.value.forEach(el => commands.push(this.browser.elementIdText(el.ELEMENT)));
const selected = await this.browser.unify(commands, { extractValue: true });
if (strict) return equals(description)assertType;
return stringIncludes(description)assertType;
}
async function findClickable(locator, locateFn) {
locator = new Locator(locator);
if (!locator.isFuzzy()) return locateFn(locator.simplify(), true);
if (locator.isAccessibilityId()) return locateFn(withAccessiblitiyLocator.call(this, locator.value), true);
let els;
const literal = xpathLocator.literal(locator.value);
els = await locateFn(Locator.clickable.narrow(literal));
if (els.value.length) return els;
els = await locateFn(Locator.clickable.wide(literal));
if (els.value.length) return els;
els = await locateFn(Locator.clickable.self(literal));
if (els.value.length) return els;
return locateFn(locator.value); // by css or xpath
}
async function findFields(locator) {
locator = new Locator(locator);
if (!locator.isFuzzy()) return this._locate(locator.simplify(), true);
if (locator.isAccessibilityId()) return this._locate(withAccessiblitiyLocator.call(this, locator.value), true);
const literal = xpathLocator.literal(locator.value);
let els = await this._locate(Locator.field.byText(literal));
if (els.value.length) return els;
els = await this._locate(Locator.field.byName(literal));
if (els.value.length) return els;
return this._locate(locator.value); // by css or xpath
}
async function proceedSeeField(assertType, field, value) {
const res = await findFields.call(this, field);
assertElementExists(res, field, 'Field');
const proceedMultiple = (fields) => {
let commands = [];
fields.forEach(el => commands.push(this.browser.elementIdSelected(el.ELEMENT)));
this.browser.unify(commands).then(() => {
commands = [];
fields.forEach((el) => {
if (el.value === false) return;
commands.push(this.browser.elementIdAttribute(el.ELEMENT, 'value'));
});
return this.browser.unify(commands, {
extractValue: true,
}).then(val => stringIncludes(fields by ${field})assertType);
});
};
const proceedSingle = el => this.browser.elementIdAttribute(el.ELEMENT, 'value').then(res => stringIncludes(fields by ${field})assertType);
const tag = await this.browser.elementIdName(res.value[0].ELEMENT);
if (tag.value === 'select') {
return proceedMultiple(res.value);
}
if (tag.value === 'input') {
return this.browser.elementIdAttribute(res.value[0].ELEMENT, 'type').then((type) => {
if (type.value === 'checkbox' || type.value === 'radio') {
return proceedMultiple(res.value);
}
return proceedSingle(res.value[0]);
});
}
return proceedSingle(res.value[0]);
}
async function proceedSeeCheckbox(assertType, field) {
const res = await findFields.call(this, field);
assertElementExists(res, field, 'Field');
const commands = [];
res.value.forEach(el => commands.push(this.browser.elementIdSelected(el.ELEMENT)));
const selected = await this.browser.unify(commands, { extractValue: true });
return truth(checkable field ${field}, 'to be checked')assertType;
}
async function findCheckable(locator, locateFn) {
let els;
locator = new Locator(locator);
if (!locator.isFuzzy()) return locateFn(locator.simplify(), true);
if (locator.isAccessibilityId()) return locateFn(withAccessiblitiyLocator.call(this, locator.value), true);
const literal = xpathLocator.literal(locator.value);
els = await locateFn(Locator.checkable.byText(literal));
if (els.value.length) return els;
els = await locateFn(Locator.checkable.byName(literal));
if (els.value.length) return els;
return locateFn(locator.value); // by css or xpath
}
function withStrictLocator(locator) {
locator = new Locator(locator);
if (locator.isAccessibilityId()) return withAccessiblitiyLocator.call(this, locator.value);
return locator.simplify();
}
function isFrameLocator(locator) {
locator = new Locator(locator);
if (locator.isFrame()) return locator.value;
return false;
}
function withAccessiblitiyLocator(locator) {
if (this.isWeb === false) {
return accessibility id:${locator.slice(1)};
}
return [aria-label="${locator.slice(1)}"];
// hook before webdriverio supports native ~ locators in web
}
function assertElementExists(res, locator, prefix, suffix) {
if (!res.value || res.value.length === 0) {
throw new ElementNotFound(locator, prefix, suffix);
}
}
function prepareLocateFn(context) {
if (!context) return this._locate.bind(this);
let el;
return (l) => {
if (el) return this.browser.elementIdElements(el, l);
return this._locate(context, true).then((res) => {
assertElementExists(res, context, 'Context element');
return this.browser.elementIdElements(el = res.value[0].ELEMENT, l);
});
};
}
module.exports = WebDriverIO;
You didn't replace the whole function definition.
And please use git gists instead of posting whole files here.
Use this WebDriverIO.js file and try again.
https://gist.github.com/reubenmiller/f070176d4efca6ab63c2b761ee94ec10
@reubenmiller : sorry to mess up the comments with large paste of file,I will use git gists from now.
I just replaced my WebdriverIO.js with the one you shared with me.
Still I am getting the same error and below is the error message.
D:\FV_Automation_Debug\Projects\Qdabra\SourceCode\AutomationTestScripts\Source>n
pm run codeceptjs fv_manageTemplate_test.js
[email protected] codeceptjs D:\FV_Automation_Debug\Projects\Qdabra\SourceCod
e\AutomationTestScripts\Source
codeceptjs run -R mocha-multi "fv_manageTemplate_test.js"
null
CodeceptJS v1.1.2
Using test root "D:\FV_Automation_Debug\Projects\Qdabra\SourceCode\AutomationTes
tScripts\Source"
ManageTemplate page --
x "before all" hook: codeceptjs.beforeSuite in 4434ms
Error: unknown command: session/46f5fdb4d96ddf5d856a52882a550f70/window/rect
-- FAILURES:
1) ManageTemplate page
"before all" hook: codeceptjs.beforeSuite:
unknown command: session/46f5fdb4d96ddf5d856a52882a550f70/window/rect
Run with --verbose flag to see NodeJS stacktrace
I think this is something to do with your setup of your selenium standalone server (maybe something to do with your last comment in issue #878).
@reubenmiller : I tried to Run java -jar -Dwebdriver.ie.driver=IEDriverServer.exe selenium-server-standalone-2.53.1.jar and then Run my tests ,again I am getting the same error.
So its sure that its not related to selenium server setup of mines as with same setup it was working earlier,but all of sudden from last 6-7 days its giving error.
Ok, next try. I cloned my Codeceptjs-starter project and edited the ./node_modules/codeceptjs/lib/helper/WebDriverIO.js with the contents from my updated gist.
So can you try and debug it:
Replace the ./node_modules/codeceptjs/lib/helper/WebDriverIO.js file with contents from this updated gist.
Though if that does not work, can you just change the windowSize property in your config file to 1024x720? If specifying an exact size works then we have narrowed it down to the maximize logic. Otherwise it is something weird with your selenium server config.
Let me know the results
@reubenmiller : I followed the Debug option 1,after that again it got failed for me...then I opt Debug option 2 and guess what again it got failed.
After that it just clicked in my mind to download the latest Chromedriver and this time it worked for me,so basically I was having old version of Chromedriver .
Strange thing is that on my client server I am using the latest ChromeDriver i.e. 2.33 and few days back I was got this error for 2 to 3 days continuously and since yesterday its not coming,so as off now changing the chromedriver worked for me on my local machine.
I will let you know if this fails on my server with this latest chromedriver again.
Thanks for this great help and Yes this change of WebdriverIO also worked I think :)