Selenium
How to Create Firefox Profile in Selenium WebDriver
Firefox profile is the collection of settings, customization, add-ons and other personalization...
Image links are the links in web pages represented by an image which when clicked navigates to a different window or 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. The first method is more preferred because of its simplicity.
In the example below, we will access the "Facebook" logo on the upper left portion of Facebook's Password Recovery page.
We will use By.cssSelector and the element's "title" attribute to access the image link. And then we will verify if we are taken to Facebook's homepage.
package newproject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class MyClass {
public static void main(String[] args) {
String baseUrl = "https://www.facebook.com/login/identify?ctx=recover";
System.setProperty("webdriver.chrome.driver","G:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get(baseUrl);
//click on the "Facebook" logo on the upper left portion
driver.findElement(By.cssSelector("a[title=\"Go to Facebook home\"]")).click();
//verify that we are now back on Facebook's homepage
if (driver.getTitle().equals("Facebook - log in or sign up")) {
System.out.println("We are back at Facebook's homepage");
} else {
System.out.println("We are NOT in Facebook's homepage");
}
driver.close();
}
}
Result
Conclusion:
This is all to clicking images. Accessing image link is done using By.cssSelector()
Firefox profile is the collection of settings, customization, add-ons and other personalization...
In this tutorial, you will learn how to integrate Cucumber with Selenium Webdriver. What is...
What is Data Scraping using selenium? Selenium can be classified as the automation tool that...
In Selenium automation, if the elements are not found by the general locators like id, class,...
What is AutoIt? AutoIt is a freeware scripting language designed for automating windows GUI and...
Selenium supports Python and thus can be utilized as Selenium WebDriver with Python for testing....