Skip to content

Commit 44bedc8

Browse files
committed
[JS] Add code sample for window size and position
1 parent 5c373c2 commit 44bedc8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

examples/javascript/test/interactions/windows.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,34 @@ describe('Interactions - Windows', function () {
8585
const windowsAfterClose = await driver.getAllWindowHandles();
8686
assert.strictEqual(windowsAfterClose.length, 2);
8787
});
88+
89+
it('Should be able to getWindow Size', async function () {
90+
await driver.get('https://www.selenium.dev/selenium/web/');
91+
92+
// Access each dimension individually
93+
const { width, height } = await driver.manage().window().getRect();
94+
95+
// Or store the dimensions and query them later
96+
const rect = await driver.manage().window().getRect();
97+
const windowWidth = rect.width;
98+
const windowHeight = rect.height;
99+
100+
assert.ok(windowWidth>0);
101+
assert.ok(windowHeight>0);
102+
});
103+
104+
it('Should be able to getWindow position', async function () {
105+
await driver.get('https://www.selenium.dev/selenium/web/');
106+
107+
// Access each dimension individually
108+
const { x, y } = await driver.manage().window().getRect();
109+
110+
// Or store the dimensions and query them later
111+
const rect = await driver.manage().window().getRect();
112+
const x1 = rect.x;
113+
const y1 = rect.y;
114+
115+
assert.ok(x1>=0);
116+
assert.ok(y1>=0);
117+
});
88118
});

0 commit comments

Comments
 (0)