This Is the Image/ Logo link that we will access :
Image or Logo links are images that act as references to other sites or sections within the same page. Since they are images, we cannot use the By.linkText() and By.partialLinkText() methods because image links basically have no link texts at all. In this case, we should resort to using either By.cssSelector or By.xpath. .
we will access the "LinkedIn" logo on the upper left portion of LinkedIn Password Recovery page.
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class AccessImage {
public static void main(String[] args) {
String baseUrl = "https://www.facebook.com/login/identify?ctx=recover";
WebDriver driver = new FirefoxDriver();
driver.get(baseUrl);
//click on the logo on the upper left portion
driver.findElement(By.cssSelector("a[title=\"Go to Facebook Home\"]")).click();
//verify that we are now back on homepage
if (driver.getTitle().equals("Welcome to Facebook - Log In, Sign Up or Learn More")) {
System.out.println("This is my homepage");
} else {
System.out.println("I am NOT in Facebook's homepage");
}
driver.quit();
}
}
Result :