Skip to content

Commit b47e051

Browse files
author
David Haeffner
committed
Made setWindowSize optional when emitting for the runner. Band-aid fix for issue #627
1 parent 14a1a36 commit b47e051

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

packages/selianize/__tests__/__snapshots__/command.spec.js.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ exports[`command code emitter should emit \`mouse over\` event 1`] = `"await dri
2121
exports[`command code emitter should emit \`mouse up at\` event 1`] = `"await driver.wait(until.elementLocated(By.id(\`button\`)), configuration.timeout);await driver.findElement(By.id(\`button\`)).then(element => {return driver.actions({bridge: true}).move({origin: element}).release().perform();});"`;
2222
2323
exports[`command code emitter should emit \`mouse up\` event 1`] = `"await driver.wait(until.elementLocated(By.id(\`button\`)), configuration.timeout);await driver.findElement(By.id(\`button\`)).then(element => {return driver.actions({bridge: true}).move({origin: element}).release().perform();});"`;
24+
25+
exports[`command code emitter should emit \`set window size\` command 1`] = `
26+
"try {
27+
await driver.manage().window().setRect({ width: 100, height: 100 });
28+
} catch(error) {
29+
console.log('Unable to resize window. Skipping.');
30+
};"
31+
`;

packages/selianize/__tests__/command.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,14 @@ describe('command code emitter', () => {
602602
}\`);`
603603
)
604604
})
605+
it('should emit `set window size` command', () => {
606+
const command = {
607+
command: 'setWindowSize',
608+
target: '100x100',
609+
value: '',
610+
}
611+
return expect(CommandEmitter.emit(command)).resolves.toMatchSnapshot()
612+
})
605613
it('should emit `store` command', () => {
606614
const command = {
607615
command: 'store',

packages/selianize/src/command.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,11 @@ function emitSetSpeed() {
804804
function emitSetWindowSize(size) {
805805
const [width, height] = size.split('x')
806806
return Promise.resolve(
807-
`await driver.manage().window().setRect({ width: ${width}, height: ${height} });`
807+
`try {
808+
await driver.manage().window().setRect({ width: ${width}, height: ${height} });
809+
} catch(error) {
810+
console.log('Unable to resize window. Skipping.');
811+
};`
808812
)
809813
}
810814

0 commit comments

Comments
 (0)