Merge branch 'MDL-58948_chrome_mink_driver' of https://github.com/mrmark/moodle
This commit is contained in:
@@ -66,7 +66,7 @@ class behat_block_comments extends behat_base {
|
||||
$this->find_link(get_string('savecomment'))->click();
|
||||
// Delay after clicking so that additional comments will have unique time stamps.
|
||||
// We delay 1 second which is all we need.
|
||||
$this->getSession()->wait(1000, false);
|
||||
$this->getSession()->wait(1000);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -104,7 +104,7 @@ class behat_block_comments extends behat_base {
|
||||
);
|
||||
|
||||
// Wait for the animation to finish, in theory is just 1 sec, adding 4 just in case.
|
||||
$this->getSession()->wait(4 * 1000, false);
|
||||
$this->getSession()->wait(4 * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1830,7 +1830,7 @@ class behat_course extends behat_base {
|
||||
$node->click();
|
||||
|
||||
// Smooth expansion.
|
||||
$this->getSession()->wait(1000, false);
|
||||
$this->getSession()->wait(1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -279,7 +279,7 @@ Console.prototype = {
|
||||
if (!this.categoriesinit) {
|
||||
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'a[data-action]', this);
|
||||
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'input[name="bcat[]"]', this);
|
||||
this.get('categorylisting').delegate('click', this.handleBulkSortByaction, '#menuselectsortby', this);
|
||||
this.get('categorylisting').delegate('change', this.handleBulkSortByaction, '#menuselectsortby', this);
|
||||
this.categoriesinit = true;
|
||||
Y.log(count + ' categories being managed', 'info', 'moodle-course-management');
|
||||
} else {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -278,7 +278,7 @@ Console.prototype = {
|
||||
if (!this.categoriesinit) {
|
||||
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'a[data-action]', this);
|
||||
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'input[name="bcat[]"]', this);
|
||||
this.get('categorylisting').delegate('click', this.handleBulkSortByaction, '#menuselectsortby', this);
|
||||
this.get('categorylisting').delegate('change', this.handleBulkSortByaction, '#menuselectsortby', this);
|
||||
this.categoriesinit = true;
|
||||
} else {
|
||||
}
|
||||
|
||||
+1
-1
@@ -277,7 +277,7 @@ Console.prototype = {
|
||||
if (!this.categoriesinit) {
|
||||
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'a[data-action]', this);
|
||||
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'input[name="bcat[]"]', this);
|
||||
this.get('categorylisting').delegate('click', this.handleBulkSortByaction, '#menuselectsortby', this);
|
||||
this.get('categorylisting').delegate('change', this.handleBulkSortByaction, '#menuselectsortby', this);
|
||||
this.categoriesinit = true;
|
||||
Y.log(count + ' categories being managed', 'info', 'moodle-course-management');
|
||||
} else {
|
||||
|
||||
@@ -62,8 +62,11 @@ class behat_groups extends behat_base {
|
||||
$select->selectOption($fulloption);
|
||||
|
||||
// This is needed by some drivers to ensure relevant event is triggred and button is enabled.
|
||||
$script = "Syn.trigger('change', {}, {{ELEMENT}})";
|
||||
$this->getSession()->getDriver()->triggerSynScript($select->getXpath(), $script);
|
||||
$driver = $this->getSession()->getDriver();
|
||||
if ($driver instanceof \Moodle\BehatExtension\Driver\MoodleSelenium2Driver) {
|
||||
$script = "Syn.trigger('change', {}, {{ELEMENT}})";
|
||||
$driver->triggerSynScript($select->getXpath(), $script);
|
||||
}
|
||||
$this->getSession()->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS);
|
||||
|
||||
// Here we don't need to wait for the AJAX response.
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
||||
|
||||
use Behat\Mink\Exception\ExpectationException as ExpectationException,
|
||||
use Behat\Mink\Exception\DriverException,
|
||||
Behat\Mink\Exception\ExpectationException as ExpectationException,
|
||||
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
|
||||
Behat\Mink\Element\NodeElement as NodeElement;
|
||||
|
||||
@@ -335,8 +336,6 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
|
||||
if (!$exception) {
|
||||
$exception = $e;
|
||||
}
|
||||
// We wait until no exception is thrown or timeout expires.
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
@@ -727,7 +726,7 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
|
||||
$pending = '';
|
||||
try {
|
||||
$jscode = '
|
||||
return function() {
|
||||
return (function() {
|
||||
if (typeof M === "undefined") {
|
||||
if (document.readyState === "complete") {
|
||||
return "";
|
||||
@@ -741,7 +740,7 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
|
||||
} else {
|
||||
return "incomplete"
|
||||
}
|
||||
}();';
|
||||
}());';
|
||||
$pending = $this->getSession()->evaluateScript($jscode);
|
||||
} catch (NoSuchWindow $nsw) {
|
||||
// We catch an exception here, in case we just closed the window we were interacting with.
|
||||
@@ -883,6 +882,8 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
|
||||
|
||||
} catch (NoSuchWindow $e) {
|
||||
// If we were interacting with a popup window it will not exists after closing it.
|
||||
} catch (DriverException $e) {
|
||||
// Same reason as above.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -959,7 +960,12 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
|
||||
}
|
||||
$this->ensure_node_is_visible($node); // Ensures hidden elements can't be clicked.
|
||||
$xpath = $node->getXpath();
|
||||
$script = "Syn.click({{ELEMENT}})";
|
||||
$this->getSession()->getDriver()->triggerSynScript($xpath, $script);
|
||||
$driver = $this->getSession()->getDriver();
|
||||
if ($driver instanceof \Moodle\BehatExtension\Driver\MoodleSelenium2Driver) {
|
||||
$script = "Syn.click({{ELEMENT}})";
|
||||
$driver->triggerSynScript($xpath, $script);
|
||||
} else {
|
||||
$driver->click($xpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,9 +108,12 @@ class behat_form_checkbox extends behat_form_field {
|
||||
* Trigger on change event.
|
||||
*/
|
||||
protected function trigger_on_change() {
|
||||
$this->session->getDriver()->triggerSynScript(
|
||||
$this->field->getXPath(),
|
||||
"Syn.trigger('change', {}, {{ELEMENT}})"
|
||||
);
|
||||
$driver = $this->session->getDriver();
|
||||
if ($driver instanceof \Moodle\BehatExtension\Driver\MoodleSelenium2Driver) {
|
||||
$driver->triggerSynScript(
|
||||
$this->field->getXPath(),
|
||||
"Syn.trigger('change', {}, {{ELEMENT}})"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,8 @@ class behat_form_field {
|
||||
// If the JS handler attached to keydown or keypress destroys the element
|
||||
// the later events may trigger errors because form element no longer exist
|
||||
// or is not visible. Ignore such exceptions here.
|
||||
} catch (\Behat\Mink\Exception\ElementNotFoundException $e) {
|
||||
// Other Mink drivers can throw this for the same reason as above.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,11 @@ class behat_form_select extends behat_form_field {
|
||||
if (!$node = $this->session->getDriver()->find($dialoguexpath)) {
|
||||
$script = "Syn.trigger('change', {}, {{ELEMENT}})";
|
||||
try {
|
||||
$this->session->getDriver()->triggerSynScript($this->field->getXpath(), $script);
|
||||
$this->session->getDriver()->click('//body//div[@class="skiplinks"]');
|
||||
$driver = $this->session->getDriver();
|
||||
if ($driver instanceof \Moodle\BehatExtension\Driver\MoodleSelenium2Driver) {
|
||||
$driver->triggerSynScript($this->field->getXpath(), $script);
|
||||
}
|
||||
$driver->click('//body//div[@class="skiplinks"]');
|
||||
} catch (\Exception $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -143,7 +143,7 @@ class behat_general extends behat_base {
|
||||
|
||||
// Wait until the URL change is executed.
|
||||
if ($this->running_javascript()) {
|
||||
$this->getSession()->wait($waittime * 1000, false);
|
||||
$this->getSession()->wait($waittime * 1000);
|
||||
|
||||
} else if (!empty($url)) {
|
||||
// We redirect directly as we can not wait for an automatic redirection.
|
||||
@@ -253,7 +253,7 @@ class behat_general extends behat_base {
|
||||
*/
|
||||
public function i_wait_seconds($seconds) {
|
||||
if ($this->running_javascript()) {
|
||||
$this->getSession()->wait($seconds * 1000, false);
|
||||
$this->getSession()->wait($seconds * 1000);
|
||||
} else {
|
||||
sleep($seconds);
|
||||
}
|
||||
@@ -634,6 +634,9 @@ class behat_general extends behat_base {
|
||||
} catch (WebDriver\Exception\NoSuchElement $e) {
|
||||
// Do nothing just return, as element is no more on page.
|
||||
return true;
|
||||
} catch (ElementNotFoundException $e) {
|
||||
// Do nothing just return, as element is no more on page.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1610,7 +1613,12 @@ class behat_general extends behat_base {
|
||||
}
|
||||
// Gets the node based on the requested selector type and locator.
|
||||
$node = $this->get_selected_node($selectortype, $element);
|
||||
$this->getSession()->getDriver()->post_key("\xEE\x80\x84", $node->getXpath());
|
||||
$driver = $this->getSession()->getDriver();
|
||||
if ($driver instanceof \Moodle\BehatExtension\Driver\MoodleSelenium2Driver) {
|
||||
$driver->post_key("\xEE\x80\x84", $node->getXpath());
|
||||
} else {
|
||||
$driver->keyDown($node->getXpath(), "\t");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user