diff --git a/config-dist.php b/config-dist.php index be49ca731f7..2791f256a77 100644 --- a/config-dist.php +++ b/config-dist.php @@ -930,6 +930,12 @@ $CFG->admin = 'admin'; // Example: // $CFG->behat_increasetimeout = 3; // +// Yon can specify a window size modifier for Behat, which is applied to any window szie changes. +// For example, if a window size of 640x768 is specified, with a modifier of 2, then the final size is 1280x1536. +// This is particularly useful for behat reruns to eliminate issues with window sizing. +// Example: +// $CFG->behat_window_size_modifier = 1; +// // Including feature files from directories outside the dirroot is possible if required. The setting // requires that the running user has executable permissions on all parent directories in the paths. // Example: diff --git a/lib/behat/classes/behat_session_trait.php b/lib/behat/classes/behat_session_trait.php index 432cd82bce5..5f7dd202348 100644 --- a/lib/behat/classes/behat_session_trait.php +++ b/lib/behat/classes/behat_session_trait.php @@ -742,6 +742,8 @@ trait behat_session_trait { * @throws ExpectationException */ protected function resize_window($windowsize, $viewport = false) { + global $CFG; + // Non JS don't support resize window. if (!$this->running_javascript()) { return; @@ -769,6 +771,12 @@ trait behat_session_trait { $width = (int) $size[0]; $height = (int) $size[1]; } + + if (isset($CFG->behat_window_size_modifier) && is_numeric($CFG->behat_window_size_modifier)) { + $width *= $CFG->behat_window_size_modifier; + $height *= $CFG->behat_window_size_modifier; + } + if ($viewport) { // When setting viewport size, we set it so that the document width will be exactly // as specified, assuming that there is a vertical scrollbar. (In cases where there is