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

前端 未结 9 1003
抹茶落季
抹茶落季 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:10

    you have to use

    storeAttribute

    And at the target place u have to mention like this

    //img[@src='imagename.png']@src.

    And store that in a variable lets say

    img

    Now verify that by using

    verifyAttribute

    eg:command:

    verifyAttribute

    target:

    //img[@src='imagename.png']@src

    value:

    ${img}

提交回复
热议问题