Tutorial SeleniumAutomation STM
Tutorial SeleniumAutomation STM
This tutorial would help you to login into your Facebook Account using Selenium WebDriver using
FireFox Browser. The code discussed in this tutorial can be easily extended to design test cases to
test the various UI elements of the Facebook Login Page.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
System.setProperty("webdriver.gecko.driver","D:\\geckodriver.exe");
System.exit(0);
}
Important:
Download 1:
a) selenium-server-standalone-3.6.0.jar
(Link: http://www.seleniumhq.org/download/)
b) client-combined-3.6.0.jar
(Link: http://www.seleniumhq.org/download/)
Add them to your project and add them to the Build Path of the project.
Download 2:
For interfacing with FireFox browser, you need to download the following jar file and
place it on your system:
a) geckodriver.exe
(Link: https://github.com/mozilla/geckodriver/releases)
[Modify the path for this file accordingly in your code]
Tip:
In case you get a compilation error on the following line for the sendKeys() method:
emailElement.sendKeys("your login id here");
1. Right click on your java project and select Build Path -> Click on
Configure Build Path...
2. In project properties window, Click Java Compiler at the left
panel
3. At the right panel, change the Compiler compliance level from 1.4 to 1.7
(Select which is higher version in your eclipse)
4. Lastly click on Apply and OK
Related Explanation:
In order to extract the unique ids of individual UI elements of a webpage, right click on the UI
element and select “Inspect Element”. You will see some HTML code which gets open in a
window at the bottom of the page. You will also see the selected element as being highlighted
in the code. Now right-click on this selected code and select ‘Copy-> Outer HTML’ and paste
on a notepad.
You will get the unique id of this element which can be used in Java code for referring this
element.