Skip to content

Instantly share code, notes, and snippets.

@rutcreate
Last active December 11, 2015 17:48
Show Gist options
  • Save rutcreate/4637345 to your computer and use it in GitHub Desktop.
Save rutcreate/4637345 to your computer and use it in GitHub Desktop.
PHPUnit Selenium
<html>
<head>
<title>Register</title>
</head>
<body>
<form action="register.php" id="register_form">
<input name="username" type="text" />
<input name="password" type="password" />
<input name="confirm" type="password" />
<input name="fullname" type="text" />
<input name="email" type="text" />
<input name="submit" type="submit" value="Register" />
</form>
</body>
</html>
<?php
class TestRegisterForm extends PHPUnit_Extensions_Selenium2TestCase {
public function setUp() {
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowser('firefox');
$this->setBrowserUrl('http://localhost/');
}
public function testFormInputsExist() {
$this->url('register.php');
$form = $this->byCssSelector('form#register_form');
$username = $this->byName('username');
$password = $this->byName('password');
$confirm = $this->byName('confirm');
$fullname = $this->byName('fullname');
$email = $this->byName('email');
$submit = $this->byName('submit');
$this->assertEquals('Register', $this->title());
$this->assertContains('register.php', $form->attribute('action'));
$this->assertEquals('text', $username->attribute('type'));
$this->assertEquals('password', $password->attribute('type'));
$this->assertEquals('password', $confirm->attribute('type'));
$this->assertEquals('submit', $submit->attribute('type'));
$this->assertEquals('Register', $submit->value());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment