Commit graph

456 commits

Author SHA1 Message Date
Tim Hunt
d40a865a2b MDL-73070 Behat: stop using no-longer-existant classes in behat_hooks 2021-11-23 10:59:26 +00:00
Paul Holden
7b22dff89a MDL-72696 behat: support inplace editable fields of type select.
If an inplace editable field is using the "select" type, we should
treat it as a select field when setting it's value during scenarios.
2021-11-08 13:12:25 +00:00
Shamim Rezaie
3c1f14fb22 Merge branch 'MDL-72874-311' of git://github.com/andrewnicols/moodle into MOODLE_311_STABLE 2021-10-29 03:34:47 +11:00
Andrew Nicols
babe07eec3 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.
2021-10-21 10:26:01 +08:00
sam marshall
b449a10a09 MDL-72849 tool_behat: Use of xpath name() not compatible with Firefox
The xpath name() function returns upper-case e.g. 'IMG' in Firefox and
lower-case e.g. 'img' in Chrome.
2021-10-19 13:49:52 +01:00
Andrew Nicols
4f4e9b4828 MDL-72593 behat: Improve behat handling of file manager buttons
When using a try/catch for a find if the first match is not met then we
have an implicit 6 second delay waiting for the search to time out.

We can avoid this by combining the searches in a comma-separated
selection.

I have also taken the opportunity to convert the use of ->click() to the
i_click_on function which has the benefit of supporting wait for
pendingJS.
2021-09-21 16:00:41 +08:00
Andrew Nicols
4258188126 MDL-72593 behat: Load the Field node content locally for processing
The standard NodeElement functions for getAttribute, getTagName,
getParent, and friends go back to WebDriver and parse the DOM for each
request. This is insanely slow per request, and in the case of forms we
do a lot of checking to determine the field type.

This change modifies the form field detection to copy the entire node
content into a DOMDocument and parse the document locally.

This is significantly faster - in some cases where there are large
documents minutes faster.

I believe that this should be a safe change as the document fetched from
the browser is normalised to match the doctype specified.
2021-09-21 16:00:41 +08:00
Ilya Tregubov
8521213b82 MDL-72262 behat: Make alias shorter to fix Oracle failures. 2021-08-02 08:26:39 +02:00
Andrew Nicols
3dd5ef4cc0 MDL-72179 behat: Make use of page resolvers 2021-07-26 15:14:24 +08:00
Andrew Nicols
9f1f8e584f MDL-72179 behat: Add page resolver for activity names 2021-07-23 20:43:47 +08:00
Andrew Nicols
995ceb32d0 MDL-72179 behat: Improve core page resolvers
This commit makes the following improvements to core page resolverss:
* allows for mixed case naming (course, Course, etc.)
* allows fields other than the idnumber to be specified:
** course: idnumber, shortname, fullname
** course category: idnumber, name

Whilst some of these fields are not unique, they will typically be
unique in most test scenarios. Where they are not then the idnumber
should be used in preference.
2021-07-23 20:28:10 +08:00
Andrew Nicols
2fe23b9295 MDL-72125 behat: Add get_activity_id() behat generators helper 2021-07-16 12:33:56 +08:00
Andrew Nicols
c9a309ed6a MDL-72125 testing: Set a default idnumber when creating activities
The activity generator currently requires an idnumber when creating
activities, but this is not a requirement when creating the same
activity through the UI. The requirement comes because we want to
provide a way to refer to activities in subsequent steps.

This commit modifies the behaviour such that the generator uses the name
of the activity as the default idnumber.

This has two  main benefits:
1. it simplfies generation of activities; and
2. it makes the language used when writing behat tests much more natural.

With this change, steps will refer to the activity by its idnumber/title
in all cases, rather than sometimes by an idnumber which bears no
relevance to the title.
2021-07-16 12:33:56 +08:00
Andrew Nicols
4abe3027d8 MDL-71874 behat: Show warning when using add to section without js 2021-06-09 16:27:19 +08:00
Jake Dallimore
8732156670 Merge branch 'MDL-52724-311' of git://github.com/merrill-oakland/moodle into MOODLE_311_STABLE 2021-05-03 13:25:20 +08:00
Andrew Nicols
66131d9307 Merge branch 'MDL-70909-311' of git://github.com/ferranrecio/moodle into MOODLE_311_STABLE 2021-04-28 10:25:44 +08:00
Ferran Recio
cd97f217b6 MDL-70909 behat: context freeze and not freeze steps 2021-04-22 15:51:36 +02:00
Noel De Martin
5c1cf60ae4 MDL-71386 behat: Support for 3.9.5+ mobile app 2021-04-22 12:15:37 +02:00
Eric Merrill
c88ad5c182 MDL-52724 editor_atto: Scrub atto html for invalid ol, ul, and li tags
Try to correct broken ul/ol/li tags, as they have an outsized impact
on course layout. Uses basic regex and loops to track open and closed
tags.

Also adds a deep clean option to the HTML cleaner, that runs less
frequent, more intensive cleanings. This is because normally _cleanHTML
gets called after each keystroke, which could cause problems with
large content on weak systems.

Behat changes are a fix for setting multiline strings in Atto, and
creating a multiline match step.
2021-04-08 15:26:55 -04:00
Eloy Lafuente (stronk7)
66dbfadd2d MDL-71264 behat: Change date(time) element update order
This includes 2 change to the order date(time) elements are filled,
each one addressing one type of problem, where current order is
problematic and can lead to unexpected dates.

1) Changing date, when current month only has X days and target
   month has more than X days. Example, being 1 April, change
   the date to 31 May.
     This is solved by changing the order of introduction
     from current D => M => Y to Y => M => D.
2) Changing date, when target month only has X days and current
   month has more that X days. Example, being 31 March, change
   the date to 28 Feb.
     This is solved by always setting the D to 1, before the
     Y => M => D sequence commented @ 1) begins.
2021-04-06 16:25:49 +02:00
sam marshall
f21cf5bc86 MDL-45242 Testing: Generators for user profile fields 2021-03-08 09:17:03 +00:00
Eloy Lafuente (stronk7)
bbe91c4828 MDL-70876 php80: 5th param removed from custom error handlers
It was deprecated in php72 and now it's gone.

Have used this regexp to find all the uses in core:

ag set_error_handler | uniq

And then checked all them manually, that parameter was not
being used in the 3 methods where we are removing it.
2021-02-26 13:08:31 +01:00
Jun Pataleta
7f23a739ed Merge branch 'MDL-47410-311' of git://github.com/andrewnicols/moodle into MOODLE_311_STABLE 2021-02-18 11:23:45 +08:00
Andrew Nicols
0b09c2556f Merge branch 'MDL-64554-311' of git://github.com/andrewnicols/moodle into MOODLE_311_STABLE 2021-02-18 10:22:45 +08:00
Andrew Nicols
6b8b548779 MDL-47410 behat: Perform exact match for date_time selectors 2021-02-18 09:34:59 +08:00
Marina Glancy
4868d7b93e MDL-64554 user: make private files editor modal/ajax form 2021-02-17 18:09:42 +01:00
Andrew Nicols
5e99241c0c Merge branch 'MDL-47410-311' of git://github.com/mihailges/moodle into MOODLE_311_STABLE 2021-02-17 09:40:14 +08:00
François Moreau
e8c98e17e6 MDL-69762 core_contentbank: let users hide their content 2021-02-15 13:49:57 -05:00
Mihail Geshoski
ac28d4fc96 MDL-47410 behat: Support selection from the datetime selector element
Adds behat support for selecting date and time from a datetime selector
element. The passed values should represent a textual date and time
description wrapped in '##' (e.g. '##first day of January 2020 08:00##',
'##1 Jan 2020 10:30##'). Also, the value 'disabled' is valid and can be
used to disable the datetime selector element.
2021-02-11 12:11:06 +08:00
Mihail Geshoski
8d7a6f740d MDL-47410 behat: Support date selection from the date selector element
Adds behat support for selecting a date from the date selector element.
The passed values should represent a textual date description wrapped
in '##' (e.g. '##first day of January 2020##', '##1 Jan 2020##'). Also,
the value 'disabled' is valid and can be used to disable the date
selector element.
2021-02-11 12:11:06 +08:00
Mihail Geshoski
bcd7a97d33 MDL-47410 behat: Create custom selector for the date and datetime fields
Creates a custom field selector to locate the requested date or datetime
form fields.
2021-02-11 12:11:06 +08:00
Mihail Geshoski
44558f34ca MDL-47410 behat: Move logic from guess_type() to a separate method
Moves the logic from guess_type() to a separate protected method
get_field_instance_for_element(). This would be quite useful for
form field classes as they can now use this method when there is
a need to determine the type of a given node element.
2021-02-11 12:11:06 +08:00
Mihail Geshoski
c70d7f624f MDL-47410 behat: Use data-fieldtype attribute to guess the field type
The data-fieldtype attribute (if present) should be also utilized in
guess_field_type() and match the behavior in get_field_node_type().
2021-02-11 12:11:05 +08:00
Andrew Nicols
d5ff729197 MDL-70734 behat: Increase the WebDriver Curl timeout 2021-02-01 09:49:54 +08:00
Andrew Nicols
3d89a661df MDL-66979 behat: Add a step to set a timeout factor for a test 2021-01-29 14:18:51 +08:00
Andrew Nicols
0bac7faf90 MDL-66979 behat: Warn about old behat.yml file location 2021-01-23 20:44:23 +08:00
Andrew Nicols
19db0c4b44 MDL-66979 behat: Rename and warn on old config 2021-01-22 14:52:19 +08:00
Andrew Nicols
0bd971ebc0 MDL-66979 behat: availability field extends textarea
The availability behat field extends the textarea type, and therefore
needs to include this type.
2021-01-22 14:52:18 +08:00
Andrew Nicols
13c2654eb1 MDL-66979 behat: Improve chromeOptions configuration
Simplify the chromeOptions configuration to improve readability.
2021-01-22 14:52:18 +08:00
Andrew Nicols
f60b5ea4db MDL-66979 behat: Remove unused var 2021-01-22 14:52:18 +08:00
Andrew Nicols
ac88e330a6 MDL-66979 behat: Whitespace fix 2021-01-22 14:52:18 +08:00
Andrew Nicols
be9e3ebd34 MDL-66979 behat: Remove manually triggered events
Behat should not trigger Synthetic browser events. It is incorrect to do
so as the UI should be used to trigger events correctly.

The W3C WebDriver specification explicitly states when and where these
events will be triggered from (the browser) and therefore there is no
ambiguity and no need to synthetically trigger them from Behat.
2021-01-22 14:52:18 +08:00
Andrew Nicols
44d9f77cae MDL-66979 behat: Update passwordunmask form field control
Update the passwordunmask form field type for behat to interact with the
form element as a human would rather than via synthetic event triggers.
2021-01-22 14:52:17 +08:00
Andrew Nicols
076ec2766f MDL-66979 behat: iFrames must have a name for switchTo
The W3C WebDriver protocol supports switching of contexts using a named
context, and not the class asscoiated with that context.
2021-01-22 14:52:17 +08:00
Andrew Nicols
d196e8093b MDL-66979 behat: Handle JS on elements better
This change introduces a new function to execute Javascript directly on
a node.

This should not, ordinarily, be used directly by steps, but may be
required in other parts of the Behat interaction.
2021-01-22 14:52:17 +08:00
Andrew Nicols
2d68b303f9 MDL-66979 behat: Rename selenium config to webdriver
The PHP WebDriver Mink Driver does not necessarily require Selenium. It
supports Selenium 3 upwards, and can be used directly with ChromeDriver,
EdgeDriver, SafariDriver, GeckoDriver, and others.

It therefore uses a slightly different configuraitno path.
2021-01-22 14:52:17 +08:00
Andrew Nicols
c5d25f9017 MDL-66979 behat: Core updates for W3C WebDriver
This commit updates core Behat features to make use of the
php-webdriver/webdriver library instead of the legacy Instaclick
library.

Most of these changes relate to use of features of WebDriver which we
are required to use directly rather than through the Mink Driver.
2021-01-22 14:52:16 +08:00
Andrew Nicols
6dae4aa3ad MDL-69107 user: Fix autocomplete usages 2020-12-16 07:50:56 +08:00
Andrew Nicols
119977e663 MDL-69107 form_autocomplete: Rewrite item selection
The form_autocomplete is essentially a custom element. Unfortunately the
`setValue()` function in Mink has undesired actions so it is necessary
to write our own handling for it.

The standard Mink `setValue()` function focuses the element, sets a
value, and then blurs the element. In the case of the autocomplete this
can cause the autocomplete suggestions list to be closed in some
situations. Instead of using the setValue we click, and type the value,
but do not immediately blur.
2020-12-15 09:08:05 +08:00
Shamim Rezaie
a5b47b660b MDL-64982 behat: Remove deprecated behat timeout constants
Behat timeout constants behat_base::TIMEOUT, EXTENDED_TIMEOUT, and
REDUCED_TIMEOUT, which were deprecated in 3.7, have been removed.
2020-12-04 17:07:49 +11:00