How to locate an tag within a webpage using Selenium and Java

前端 未结 4 2060
南笙
南笙 2021-01-26 04:24

I want to locate the image tag in a webpage. The application contains a VIEW ICON. While inspecting the view icon, it is coded as image tag. I am not s

4条回答
  •  时光取名叫无心
    2021-01-26 05:04

    Try this:

    Selenium - Java

    /*get element by tag name*/
    WebElement image = driver.findElement(By.tagName("image")); 
    

    If there are more than one image on the page , use

    /*get all elements by tag name*/
    List images = driver.findElements(By.tagName("image")); 
    

    from the list above determine which one do you want to use(tip : use a foreach loop to iterate)

提交回复
热议问题