Write a test case to check if an image exists on a webpage or not without using JS Executor

0 votes
Please help me in writing a test case to check whether an image exists on a webpage or not without using JS Executor in Selenium Webdriver.
May 21, 2019 in Selenium by Nipun
3,971 views

1 answer to this question.

0 votes

@Nipun if you want to check whether an image is displayed on a webpage or not and doesn't want to use JS Executor, you can use following lines of code:

WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        
        driver.navigate().to("https://www.google.com");
        
        Thread.sleep(5000);
        
        WebElement img = driver.findElement(By.id("hplogo"));    
        
        System.out.println(img.isDisplayed());
        
        driver.close();
answered May 21, 2019 by Nikita

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,743 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,618 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,696 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,557 views
0 votes
1 answer
0 votes
1 answer

How to check if an image is displayed on web page while working with Selenium WebDriver?

I've come across a similar situation before, where the image ...READ MORE

answered May 10, 2019 in Selenium by Surya
• 970 points
7,550 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP