← Back to team overview

mahara-contributors team mailing list archive

[Bug 1897190] A change has been merged

 

Reviewed:  https://reviews.mahara.org/11400
Committed: https://git.mahara.org/mahara/mahara/commit/3f82f722552d61b1e072489e32c41b3ea616336a
Submitter: Robert Lyon (robertl@xxxxxxxxxxxxxxx)
Branch:    master

commit 3f82f722552d61b1e072489e32c41b3ea616336a
Author: Rebecca Blundell <rebecca.blundell@xxxxxxxxxxxxxxx>
Date:   Thu Oct 22 15:54:20 2020 +1300

Bug 1897190: Improve behat properties file structure

rewrite properties file and functions to make structure
easier to manage:
- add multiple arrays to split up properties by category
- modernise PHP syntax to use array constants
- fix location option to work properly
- remove need for xpath/css to be specified in arrays,
by adding set_selector_type()
- remove unused function and add others as required
- update tests to call properties, not css/xpath
- add check for null return from  get_property() and
throw ExpectationException for property if null

Change-Id: If64a5a1ed1a572b8eadcf91dd9f7a87bcf621d7c

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1897190

Title:
  Behat: Tidy up and improve behat properties file

Status in Mahara:
  Fix Committed

Bug description:
  Background:

  A while ago we set up a behat 'properties' file to hold css/xpath
  locators so they wouldn't need to be included directly in steps. When
  that was implemented, all the steps that included css/xpath references
  were taken out and replaced with the steps that call the properties
  file.

  The original idea was that as new things needed to be found by the
  test suite, they would be added to the properties file and it would
  gradually grow to cover more of the site.

  
  Now:

  Steps that call the css/xpaths directly have been appearing back in
  the tests, rather than being added to the properties file as they are
  needed. This is probably just because it is faster to not add the
  locator to the properties file and just call it directly in the test.

  
  Issues:

  1. Adding the locators directly to tests means they are harder to read.
  2. Currently the properties file is hard to read. It has different locators from anywhere in the site put into one array, so you can't easily see whether a locator for the item you want already exists.
  3. The properties file could use a refactor. We were supporting an old PHP without constant arrays and constant multi-dimensional arrays when it was written.
  4. It is faster to write a test with the locators directly than adding the locator to the properties file, so test writers may still not use it.

  
  Suggested solutions to issues:

  
  1. Refactor existing tests with css/xpath locators to use the properties file.
  2,3. Update the properties file so that it has different arrays or a single multi-dimensional array with sections related to components of the site, something like: 
  define ("HEADER", array (
    'Search'  =>'#usf_query',
    //more things
  ));

  define ("DASHBOARD", array (
    'Static pages' => "//a[contains(@href, 'site/pages')]/b",
    //more things
  ));

  define ("FOOTER", array(
    //more things
  ));

  define ("SIDEBLOCKS", array(
    //more things
  ));

  define ("BLOCKS", array (
    //more things
  ));


  4. Spend some time adding some more locators so they are covered and don't need to be added by the tester, as finding how to interact with an element is the slowest part of test writing.
  Consider the way the properties file is called. 
  - Is there an easier way than calling the properties steps? 
  - Could there be an underlying function that replaced passed in variables with locators called from all existing relevant steps? (Maybe that would create unnecessary overhead).
  - If there is a way that would make it easier to use the properties file from a dev/tester perspective, it will be used.

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1897190/+subscriptions


References