Selenium: How do I get the src of an image?

前端 未结 9 1016
抹茶落季
抹茶落季 2020-12-17 09:32

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

9条回答
  •  生来不讨喜
    2020-12-17 10:06

    You need to use XPath. For PHPUnit and Selenium the Syntax for getting the src attribute of an image is:

    $imageUrl = $this->getAttribute("//img/@src");
    

提交回复
热议问题