Skip to content

How to work with jQuery AJAX

jubishop edited this page Dec 20, 2011 · 2 revisions
$session->element('xpath', "//button[@class='button main-button add-to-cart-button']")->click();
$this->waitForAjax();
$session->element('link text', 'View cart')->click();

Where waitForAjax method is defined as

protected function waitForAjax() {
    do {
        sleep(2);
    } while($this->session->execute(array('script' => 'return jQuery.active', 'args' => array())));
}

This code works only for scripts with jQuery framework.

Original article/Other solutions http://agilesoftwaretesting.com/?p=111

Clone this wiki locally