You can use the if-else
condition in combination with an assert
in your PHPUnit test. Here's an example:
public function testProjectTitle()
{
// Get the current title of the web page
$title = $this->webDriver->getTitle();
// Check if the title contains 'Project Title'
if (strpos($title, 'Project Title') === false) {
// Display a popup or log an error message
echo 'Project title not found';
} else {
// Assert that the title contains 'Project Title'
$this->assertContains('Project Title', $title);
}
}
In this example, we first get the current title of the web page using $this->webDriver->getTitle()
. We then use an if
statement to check if the title contains 'Project Title'. If it does not, we can display a popup or log an error message using echo
. If the title does contain 'Project Title', we use the assertContains
method to assert that the title contains the expected string.
Note that if the assertion fails, PHPUnit will automatically stop the test and mark it as failed. If you want to display a popup or log a message in case of a failed assertion, you can do so in the test case's tearDown
method.