mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-58948 behat: Chrome driver has unique xpaths
Chrome driver has unique xpaths for clicking on all the show more links. So clicking on the first xpath X times does not work.
This commit is contained in:
parent
95ee1f6392
commit
7cde2bb313
@ -148,13 +148,20 @@ class behat_forms extends behat_base {
|
||||
return;
|
||||
}
|
||||
|
||||
// Funny thing about this, with findAll() we specify a pattern and each element matching the pattern is added to the array
|
||||
// with of xpaths with a [0], [1]... sufix, but when we click on an element it does not matches the specified xpath
|
||||
// anymore (now is a "Show less..." link) so [1] becomes [0], that's why we always click on the first XPath match,
|
||||
// will be always the next one.
|
||||
$iterations = count($showmores);
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
$showmores[0]->click();
|
||||
if ($this->getSession()->getDriver() instanceof \DMore\ChromeDriver\ChromeDriver) {
|
||||
// Chrome Driver produces unique xpaths for each element.
|
||||
foreach ($showmores as $showmore) {
|
||||
$showmore->click();
|
||||
}
|
||||
} else {
|
||||
// Funny thing about this, with findAll() we specify a pattern and each element matching the pattern
|
||||
// is added to the array with of xpaths with a [0], [1]... sufix, but when we click on an element it
|
||||
// does not matches the specified xpath anymore (now is a "Show less..." link) so [1] becomes [0],
|
||||
// that's why we always click on the first XPath match, will be always the next one.
|
||||
$iterations = count($showmores);
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
$showmores[0]->click();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ElementNotFoundException $e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user