Skip to content

Commit 095ddf9

Browse files
committed
Improve testWindowMaximize
1 parent a7ac65e commit 095ddf9

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

tests/Js/WindowTest.php

+24-7
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,29 @@ public function testWindowMaximize(): void
9898
{
9999
$this->getSession()->visit($this->pathTo('/index.html'));
100100
$session = $this->getSession();
101-
102-
$session->maximizeWindow();
103-
$session->wait(1000, 'false');
104-
105-
$script = 'return Math.abs(screen.availHeight - window.outerHeight);';
106-
107-
$this->assertLessThanOrEqual(100, $session->evaluateScript($script));
101+
$popupName = 'testPopup';
102+
$createWindowJs = "window.open('about:blank', '$popupName', 'left=20,top=40,width=300,height=200')";
103+
$getWindowPosJs = '
104+
return {
105+
top: window.screenY,
106+
left: window.screenX,
107+
right: window.screenX + window.innerWidth,
108+
bottom: window.screenX + window.innerHeight
109+
}
110+
';
111+
$session->executeScript($createWindowJs);
112+
$session->switchToWindow($popupName);
113+
$oldDim = (array)$session->evaluateScript($getWindowPosJs);
114+
115+
$session->maximizeWindow($popupName);
116+
$newDim = (array)$session->evaluateScript($getWindowPosJs);
117+
118+
foreach (array_keys($oldDim) as $name) {
119+
$this->assertNotEquals(
120+
$oldDim[$name],
121+
$newDim[$name],
122+
"The popup's $name position should not be the same after maximizing"
123+
);
124+
}
108125
}
109126
}

0 commit comments

Comments
 (0)