| | 123 | === Dashboard Example === |
| | 124 | |
| | 125 | {{{ |
| | 126 | <?php |
| | 127 | require_once(dirname(__FILE__).'/../bootstrap/Selenium.php'); |
| | 128 | |
| | 129 | class DashboardTest extends SiwappSeleniumTest |
| | 130 | { |
| | 131 | public function testShowPayments() |
| | 132 | { |
| | 133 | $this->login(); |
| | 134 | |
| | 135 | $this->log("::testShowPayments()"); |
| | 136 | $this->open("dashboard"); |
| | 137 | |
| | 138 | $this->log("show payment details for the most recent invoice (top table).", 'click'); |
| | 139 | |
| | 140 | $this->click("//*/table[@class=\"listing\"][1]/tbody/tr[1]/td[8]/a"); |
| | 141 | $ret = $this->waitForCondition("selenium.isElementPresent('//*/table[@class=\"listing\"][1]/tbody/tr[2]/td[1]/form[@class=\"payments-form\"]') == true"); |
| | 142 | |
| | 143 | $this->log("show payment details for the most recent overdue invoice (bottom table).", 'click'); |
| | 144 | |
| | 145 | // Bottom Table |
| | 146 | $this->click("//*/table[@class=\"listing\"][2]/tbody/tr[1]/td[7]/a"); |
| | 147 | $this->waitForCondition("selenium.isElementPresent('//*/table[@class=\"listing\"][2]/tbody/tr[2]/td[1]/form[@class=\"payments-form\"]') == true"); |
| | 148 | } |
| | 149 | } |
| | 150 | ?> |
| | 151 | }}} |
| | 152 | |
| | 153 | The `login` method performs the login action if you are not logged in. It is recommended to put that line in every test function if you don't know which one is going to be executed first. |
| | 154 | |
| | 155 | '''Important:''' Try to use relative xpath routes as much as you can because if we change the layout the test could fail. Let's see an example: |
| | 156 | |
| | 157 | {{{ |
| | 158 | BAD: |
| | 159 | //tr[@id="invoice-50"]/td[8]/a/span/span |
| | 160 | //form[@id="invoice-50_payments"] |
| | 161 | }}} |
| | 162 | |
| | 163 | {{{ |
| | 164 | OK: |
| | 165 | //*/table[@class="listing"][1]/tbody/tr[1]/td[8]/a |
| | 166 | }}} |
| | 167 | |
| | 168 | In this case we got the payments button of the first row in the first listing table. |
| | 169 | |