MDL-49334 behat: sort selector lists

This commit is contained in:
Tim Hunt 2015-02-27 13:58:16 +00:00
parent dba564c7db
commit f70fbc05e1

View File

@ -39,45 +39,45 @@ class behat_selectors {
* @var Allowed types when using text selectors arguments.
*/
protected static $allowedtextselectors = array(
'dialogue' => 'dialogue',
'block' => 'block',
'section' => 'section',
'activity' => 'activity',
'region' => 'region',
'table_row' => 'table_row',
'list_item' => 'list_item',
'table' => 'table',
'fieldset' => 'fieldset',
'block' => 'block',
'css_element' => 'css_element',
'xpath_element' => 'xpath_element'
'dialogue' => 'dialogue',
'fieldset' => 'fieldset',
'list_item' => 'list_item',
'region' => 'region',
'section' => 'section',
'table' => 'table',
'table_row' => 'table_row',
'xpath_element' => 'xpath_element',
);
/**
* @var Allowed types when using selector arguments.
*/
protected static $allowedselectors = array(
'dialogue' => 'dialogue',
'block' => 'block',
'section' => 'section',
'activity' => 'activity',
'region' => 'region',
'table_row' => 'table_row',
'list_item' => 'list_item',
'link' => 'link',
'block' => 'block',
'button' => 'button',
'link_or_button' => 'link_or_button',
'select' => 'select',
'checkbox' => 'checkbox',
'radio' => 'radio',
'file' => 'file',
'filemanager' => 'filemanager',
'optgroup' => 'optgroup',
'option' => 'option',
'table' => 'table',
'css_element' => 'css_element',
'dialogue' => 'dialogue',
'field' => 'field',
'fieldset' => 'fieldset',
'file' => 'file',
'filemanager' => 'filemanager',
'link' => 'link',
'link_or_button' => 'link_or_button',
'list_item' => 'list_item',
'optgroup' => 'optgroup',
'option' => 'option',
'radio' => 'radio',
'region' => 'region',
'section' => 'section',
'select' => 'select',
'table' => 'table',
'table_row' => 'table_row',
'text' => 'text',
'css_element' => 'css_element',
'xpath_element' => 'xpath_element'
);
@ -90,8 +90,14 @@ class behat_selectors {
* @var XPaths for moodle elements.
*/
protected static $moodleselectors = array(
'text' => <<<XPATH
//*[contains(., %locator%)][count(./descendant::*[contains(., %locator%)]) = 0]
'activity' => <<<XPATH
//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][normalize-space(.) = %locator% ]
XPATH
, 'block' => <<<XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), ' block ') and
(contains(concat(' ', normalize-space(@class), ' '), concat(' ', %locator%, ' ')) or
descendant::h2[normalize-space(.) = %locator%] or
@aria-label = %locator%)]
XPATH
, 'dialogue' => <<<XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), ' moodle-dialogue ') and
@ -101,11 +107,15 @@ XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), ' yui-dialog ') and
normalize-space(descendant::div[@class='hd']) = %locator%]
XPATH
, 'block' => <<<XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), ' block ') and
(contains(concat(' ', normalize-space(@class), ' '), concat(' ', %locator%, ' ')) or
descendant::h2[normalize-space(.) = %locator%] or
@aria-label = %locator%)]
, 'filemanager' => <<<XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), ' ffilemanager ')]
/descendant::input[@id = //label[contains(normalize-space(string(.)), %locator%)]/@for]
XPATH
, 'list_item' => <<<XPATH
.//li[contains(normalize-space(.), %locator%)]
XPATH
, 'region' => <<<XPATH
//*[self::div | self::section | self::aside | self::header | self::footer][./@id = %locator%]
XPATH
, 'section' => <<<XPATH
//li[contains(concat(' ', normalize-space(@class), ' '), ' section ')][./descendant::*[self::h3]
@ -114,24 +124,14 @@ XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), ' sitetopic ')]
[./descendant::*[self::h2][normalize-space(.) = %locator%] or %locator% = 'frontpage']
XPATH
, 'activity' => <<<XPATH
//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][normalize-space(.) = %locator% ]
XPATH
, 'region' => <<<XPATH
//*[self::div | self::section | self::aside | self::header | self::footer][./@id = %locator%]
, 'table' => <<<XPATH
.//table[(./@id = %locator% or contains(.//caption, %locator%) or contains(concat(' ', normalize-space(@class), ' '), %locator% ))]
XPATH
, 'table_row' => <<<XPATH
.//tr[contains(normalize-space(.), %locator%)]
XPATH
, 'list_item' => <<<XPATH
.//li[contains(normalize-space(.), %locator%)]
XPATH
, 'filemanager' => <<<XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), ' ffilemanager ')]
/descendant::input[@id = //label[contains(normalize-space(string(.)), %locator%)]/@for]
XPATH
, 'table' => <<<XPATH
.//table[(./@id = %locator% or contains(.//caption, %locator%) or contains(concat(' ', normalize-space(@class), ' '), %locator% ))]
, 'text' => <<<XPATH
//*[contains(., %locator%)][count(./descendant::*[contains(., %locator%)]) = 0]
XPATH
);