mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Funny thing about this, with findAll() we specify a pattern and each element matching the pattern is added to the array
|
if ($this->getSession()->getDriver() instanceof \DMore\ChromeDriver\ChromeDriver) {
|
||||||
// with of xpaths with a [0], [1]... sufix, but when we click on an element it does not matches the specified xpath
|
// Chrome Driver produces unique xpaths for each element.
|
||||||
// anymore (now is a "Show less..." link) so [1] becomes [0], that's why we always click on the first XPath match,
|
foreach ($showmores as $showmore) {
|
||||||
// will be always the next one.
|
$showmore->click();
|
||||||
$iterations = count($showmores);
|
}
|
||||||
for ($i = 0; $i < $iterations; $i++) {
|
} else {
|
||||||
$showmores[0]->click();
|
// 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) {
|
} catch (ElementNotFoundException $e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user