I\'m using Selenium (within PHPUnit) to test my web application. I would like to test whether a certain image which is present on the page really exists. More precisely, whe
If You are you using any PHP webdriver like facebook/phpwebdiver, then it will solve your problem very easily.
Example :
1) Create a wedriver object:
public function setUp()
{
parent::setUp();
$web_driver = new WebDriver();
$element = $web_driver->session();
}
With this $element
variable you can easily access any HTML attribute with the following line:
$element->element('xpath', '//*[@id="logo"]')->attribute('src');
This will return you the value of src
attibute. You can use this line to get any attribute like class, id, title, alt, etc...