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 in Selenium by Nipun
24 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 by Nikita

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

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,090 points
750 views
0 votes
1 answer
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,130 points
995 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
709 views
0 votes
1 answer