Skip to content

Instantly share code, notes, and snippets.

@heddn
Created October 9, 2012 21:10
Show Gist options
  • Save heddn/3861466 to your computer and use it in GitHub Desktop.
Save heddn/3861466 to your computer and use it in GitHub Desktop.
<?php
class ColorTest extends BaseTest {
/**
* @test
*/
public function links() {
$this->init();
// Test links
$this->assertEquals("Link Text", $this->getText("xpath=//div[@id='exampleId']/h2/a"));
$this->assertEquals("26", $this->getXpathCount("//div[@class='example_class']//a"));
$this->assertEquals("Example form text", $this->getText("xpath=//form[@id='example_form']/div/div[2]/div[1]/ul/li[2]/div/ul/li[1]/a"));
}
/**
* @test
*/
public function saveSession() {
$this->init();
// Select color
$this->click("xpath=//div[@class='example_class']/div/ul/li[2]//a");
$this->waitForPageToLoad("30000");
$this->assertEquals("Blue", $this->getText("xpath=//div[@id='breadcrumb']/div/a"));
$host = $this->getEval("window.document.domain");
$this->assertEquals("http://" . $host . "/blue", $this->getLocation());
// Visit a color site with cookie set for another color
$this->open("http://" . $host . '/green');
$this->waitForPageToLoad("30000");
$this->assertEquals("Green", $this->getText("xpath=//div[@id='breadcrumb']/div/a"));
// Visit website w/o color in url
$this->open("http://" . $host);
$this->waitForPageToLoad("30000");
$this->assertEquals("Blue", $this->getText("xpath=//h1[@id='page-title']"));
// Visit website with query string
$this->open("http://" . $host . '?q=');
$this->waitForPageToLoad("30000");
$this->assertEquals("Blue", $this->getText("xpath=//h1[@id='page-title']"));
}
/**
* @test
*/
public function colorPage() {
$this->init();
// Select color
$this->click("xpath=//div[@class='example_class']/div/ul/li[2]//a");
$this->waitForPageToLoad("30000");
$host = $this->getEval("window.document.domain");
$this->assertContains("color=blue", $this->getAttribute("xpath=//div[@id='exampleId']/div/ul/li/h3/a@href"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment