diff --git a/local_moodleappbehat/tests/behat/behat_app.php b/local_moodleappbehat/tests/behat/behat_app.php index 67776a49f..d14b2391d 100644 --- a/local_moodleappbehat/tests/behat/behat_app.php +++ b/local_moodleappbehat/tests/behat/behat_app.php @@ -45,7 +45,6 @@ class behat_app extends behat_app_helper { ]; protected $featurepath = ''; - protected $windowsize = '360x720'; /** * @BeforeScenario diff --git a/local_moodleappbehat/tests/behat/behat_app_helper.php b/local_moodleappbehat/tests/behat/behat_app_helper.php index 6c4b38c0d..f30572b01 100644 --- a/local_moodleappbehat/tests/behat/behat_app_helper.php +++ b/local_moodleappbehat/tests/behat/behat_app_helper.php @@ -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']); + } }