MOBILE-4270 behat: Fix default window size

Tests were already running with these dimensions, but we hadn't noticed because unless the tests are run in headless mode, the minimum width is 500px.
main
Noel De Martin 2023-05-11 09:46:42 +02:00
parent b3b269c8d7
commit dbd96d7181
2 changed files with 15 additions and 2 deletions

View File

@ -45,7 +45,6 @@ class behat_app extends behat_app_helper {
];
protected $featurepath = '';
protected $windowsize = '360x720';
/**
* @BeforeScenario

View File

@ -201,7 +201,7 @@ class behat_app_helper extends behat_base {
$restart = true;
// Reset its size.
$this->resize_window($this->windowsize, true);
$this->resize_app_window();
// Visit the Ionic URL.
$this->getSession()->visit($this->get_app_url());
@ -596,4 +596,18 @@ EOF;
return null;
}
/**
* Resize window to have app dimensions.
*/
protected function resize_app_window() {
$width = 500;
$height = 720;
$offset = $this->evaluate_script("{
x: window.outerWidth - document.body.offsetWidth,
y: window.outerHeight - window.innerHeight,
}");
$this->getSession()->getDriver()->resizeWindow($width + $offset['x'], $height + $offset['y']);
}
}