Hello Lalit, I guess you mean to say clicking an image on a web page using Selenium Webdriver. So to click an image using selenium webdriver, you can try this piece of code:
package clickImageProject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ClickImage{
public static void main(String[] args) {
String Url = "https://www.edureka.co/devops-certification-courses";
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get(Url);
//click on the "Edureka" logo on the upper left portion
driver.findElement(By.Xpath("//i[@class='icon-logo edu-logo-style']")).click();
//verify that we are now back on Edureka's homepage
if (driver.getTitle().equals("Instructor-Led Online Training with 24X7 Lifetime Support | Edureka")) {
System.out.println("We are back at Edureka's homepage");
} else {
System.out.println("We are NOT on Edureka's homepage");
}
driver.close();
}
}
Now, in the code above, I have used Xpath to get the image location, but you can also use CSS selector.