setBrowser('*firefox C:\lib\firefox\firefox.exe'); $this->setBrowserUrl('http://localhost/'); } private function openAndWaitForData() { $this->open('http://localhost/gridiron/test.html'); $this->waitForCondition('selenium.browserbot.getCurrentWindow().$("#grid1 .gridiron-data-container .gridiron-row").length > 0;', 2000); } public function testCanSelectAndDeselectRow() { $this->openAndWaitForData(); $this->click(self::$rowContainer . '/div[1]'); $this->assertTrue($this->isElementPresent(self::$rowContainer . '/div[1][contains(@class, "gridiron-selected")]')); $this->click(self::$rowContainer . '/div[1]'); $this->assertFalse($this->isElementPresent(self::$rowContainer . '/div[1][contains(@class, "gridiron-selected")]')); } public function testCaptionTitleIsVisible() { $this->openAndWaitForData(); $this->assertTrue($this->isElementPresent(self::$caption . '/span[contains(@class, "gridiron-title")]')); $this->assertEquals('Cities around the world', $this->getText(self::$caption . '/span[contains(@class, "gridiron-title")]')); } public function testColumnsAreRenderedCorrectly() { $this->openAndWaitForData(); $expectedText = array('City', 'Country', 'Region', 'Latitude', 'Longitude'); $this->verifyColumnHeader(1, 'City', true, 145); $this->verifyColumnHeader(2, 'Country', true, 145); $this->verifyColumnHeader(3, 'Region', true, 145); $this->verifyColumnHeader(4, 'Latitude', true, 70); $this->verifyColumnHeader(5, 'Longitude', false, 70); } private function verifyColumnHeader($index, $text, $sortable, $width) { $xpath = self::$header . '/div[contains(@class, "gridiron-cell")][%s]'; self::assertTrue($this->isElementPresent(sprintf($xpath, $index))); self::assertEquals($text, $this->getText(sprintf($xpath, $index))); self::assertContains('width: ' . $width . 'px', $this->getAttribute(sprintf($xpath . '/@style', $index))); self::assertEquals($sortable, $this->isElementPresent(sprintf($xpath . '/span[contains(@class, "gridiron-sort-indicator")]', $index))); } } ?>