MDL-49445 behat: selectors should match the most specific tr or li
I also fixed the text rule, which already did this, to use the same idiom. It is unnecessarily inefficient to count all the things and compare to 0. Not exists should be faster. Also, updated all the selectors here to consistently start relative to the current node (.//, not //).
This commit is contained in:
@@ -93,51 +93,51 @@ class behat_selectors {
|
||||
*/
|
||||
protected static $moodleselectors = array(
|
||||
'activity' => <<<XPATH
|
||||
//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][normalize-space(.) = %locator% ]
|
||||
.//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][normalize-space(.) = %locator% ]
|
||||
XPATH
|
||||
, 'block' => <<<XPATH
|
||||
//div[contains(concat(' ', normalize-space(@class), ' '), ' block ') and
|
||||
.//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
|
||||
.//div[contains(concat(' ', normalize-space(@class), ' '), ' moodle-dialogue ') and
|
||||
normalize-space(descendant::div[
|
||||
contains(concat(' ', normalize-space(@class), ' '), ' moodle-dialogue-hd ')
|
||||
]) = %locator%] |
|
||||
//div[contains(concat(' ', normalize-space(@class), ' '), ' yui-dialog ') and
|
||||
.//div[contains(concat(' ', normalize-space(@class), ' '), ' yui-dialog ') and
|
||||
normalize-space(descendant::div[@class='hd']) = %locator%]
|
||||
XPATH
|
||||
, 'filemanager' => <<<XPATH
|
||||
//div[contains(concat(' ', normalize-space(@class), ' '), ' ffilemanager ')]
|
||||
.//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%)]
|
||||
.//li[contains(normalize-space(.), %locator%) and not(.//li[contains(normalize-space(.), %locator%)])]
|
||||
XPATH
|
||||
, 'question' => <<<XPATH
|
||||
//div[contains(concat(' ', normalize-space(@class), ' '), ' que ')]
|
||||
.//div[contains(concat(' ', normalize-space(@class), ' '), ' que ')]
|
||||
[contains(div[@class='content']/div[@class='formulation'], %locator%)]
|
||||
XPATH
|
||||
, 'region' => <<<XPATH
|
||||
//*[self::div | self::section | self::aside | self::header | self::footer][./@id = %locator%]
|
||||
.//*[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]
|
||||
.//li[contains(concat(' ', normalize-space(@class), ' '), ' section ')][./descendant::*[self::h3]
|
||||
[normalize-space(.) = %locator%][contains(concat(' ', normalize-space(@class), ' '), ' sectionname ') or
|
||||
contains(concat(' ', normalize-space(@class), ' '), ' section-title ')]] |
|
||||
//div[contains(concat(' ', normalize-space(@class), ' '), ' sitetopic ')]
|
||||
.//div[contains(concat(' ', normalize-space(@class), ' '), ' sitetopic ')]
|
||||
[./descendant::*[self::h2][normalize-space(.) = %locator%] or %locator% = 'frontpage']
|
||||
XPATH
|
||||
, '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%)]
|
||||
.//tr[contains(normalize-space(.), %locator%) and not(.//tr[contains(normalize-space(.), %locator%)])]
|
||||
XPATH
|
||||
, 'text' => <<<XPATH
|
||||
//*[contains(., %locator%)][count(./descendant::*[contains(., %locator%)]) = 0]
|
||||
.//*[contains(., %locator%) and not(.//*[contains(., %locator%)])]
|
||||
XPATH
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user