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

前端 未结 4 2031
南笙
南笙 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 04:59

    Can you please execute the code below and let me know what you get. System.out.println(driver.findElements(By.tagName(“image”)).size());

    if you still get null pointer exception , there is something wrong with your driver object . This code should return 0 if no image tag found on page , else the number of image tags on that page

    Depending on the number of image tags , you can decide on the index of image tag you want to click , and then execute click on that element

提交回复
热议问题