MDL-72874 behat: Allow behat window sizes to be modified during run
In some situations it is useful to modify the requested screensize by a modifier. This allows for failing tests to be rerun at a different screensize, where the original screensize triggered a failure for some size-related reason.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user