setBrowser(TESTS_SELENIUM_BROWSER); $this->setBrowserUrl(TESTS_SELENIUM_BASEURL); } public function testLoginFormExists() { $this->open(TESTS_SELENIUM_BASEURL . 'login'); $this->assertElementPresent("id=login-form"); $this->assertElementPresent("dom=document.forms['login-form'].identity"); $this->assertElementPresent("dom=document.forms['login-form'].password"); $this->assertElementPresent("xpath=//form[@id='login-form']/input[@type='submit']"); // test maxlength of input fields matches MySQL varchar size for each $this->assertElementPresent("xpath=//input[@id='identity' and @maxlength='20']"); $this->assertElementPresent("xpath=//input[@id='password' and @maxlength='64']"); // assert the "Forgot Password" link is present $this->assertElementPresent('link=regexp:^Forgot identity or password\?'); } public function testValidAuthentication() { $this->open(TESTS_SELENIUM_BASEURL . 'login'); // Fill out the form! $this->type("dom=document.forms['login-form'].identity", 'Pádraic'); $this->type("dom=document.forms['login-form'].password", 'KSkjduj$!hjj*927'); // Submit the form! $this->click("xpath=//form[@id='login-form']/input[@type='submit']"); $this->waitForPageToLoad(TESTS_SELENIUM_DEFAULT_TIMEOUT); // Verify the login was successful $this->assertTextPresent('exact:Welcome, Pádraic!'); // And that no Error is printed $this->assertTextNotPresent('*invalid*'); } public function testInvalidAuthenticationWithError() { $this->open(TESTS_SELENIUM_BASEURL . 'login'); // Fill out the form! $this->type("dom=document.forms['login-form'].identity", 'Maugrim'); $this->type("dom=document.forms['login-form'].password", 'badpass'); // Submit the form! $this->click("xpath=//form[@id='login-form']/input[@type='submit']"); $this->waitForPageToLoad(TESTS_SELENIUM_DEFAULT_TIMEOUT); // Verify the login was unsuccessful... $this->assertTextNotPresent('regexp=Welcome,[a-zA-Z0-9 -_áóúíéÁÓÚÍÉ]'); // ...and that an Error exists! $this->assertTextPresent('*invalid*'); } }