Selenium tutorial for beginners

Introduction

  • Selenium is an open-source web-based automation tool.
  • It is an automation testing suite for web application across different browsers.
  • Selenium integrate to multiple tools like test-ng ,JUnit.
  • It is using run the tests in multiple browsers at a time.
  • The Selenium-IDE (Integrated Development Environment) it is easy to use develop selenium test cases. GUI for recording user actions and workflow.
  • Selenium grid is a tool, run parallel tests across different machines and different browsers.
  • Selenium web driver uses to Develop the script.
  • It supports only web-based applications.

Environment setup

  1. Download the java and install it (If you have already installed, please ignore it).
  2. Download the eclipse and install it. (If you have already installed, please ignore it).
  3. Then you need to install firebug and fire-path extensions for firefox browser. For chrome FirePHP extension install it.
  4. By the use of firebug and fire-path, we can get the id or XPath of the element.
Selenium Properties

import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.ie.InternetExplorerDriver; public class Linkedinn { public static void main(String[] args) { // declaration and instantiation of objects/variables System.setProperty("webdriver.ie.driver","C:\\Users\\miracle\\Downloads\\IEDriverServer.exe"); WebDriver driver = new InternetExplorerDriver(); String baseUrl = "https://www.linkedin.com/"; driver.get(baseUrl); // Get the WebElement corresponding to the Email Address(TextField) WebElement email = driver.findElement(By.id("login-email")); // Get the WebElement corresponding to the Password Field WebElement password = driver.findElement(By.name("login-password")); email.sendKeys("your email id"); password.sendKeys("your pasword"); System.out.println("Text Field Set"); // Deleting values in the text box email.clear(); password.clear(); System.out.println("Text Field Cleared"); // Find the submit button WebElement login = driver.findElement(By.id("login-submit")); login.click(); System.out.println("Login Done with Click"); driver.close(); } }

Explanation:

  1. First Download the driver from selenium official website https://www.seleniumhq.org/
  2. Download the web driver which browser you want to run all test cases.
  3. Then set the property for driver location where you placed the driver .exe file.
  4. Create the object for Driver class and based on the driver object pass the values statically.
  5. Use the predefined methods to pass the data into input fields.
  6. The driver.get method is used to navigate the page which you provided in the base URL.

SUBSCRIBE TO OUR NEWSLETTER

I’m the Founder of quickdevops.com. I am a Professional Blogger, Application developer, YouTuber. I’ve been blogging since 2015.I spend a lot of time learning new techniques and actively help other people learn web development through a variety of help groups and writing web development tutorials for my website and blog about advancements in web design and development.Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie or planning a trip to someplace I've never been before.

1 Response to "Selenium tutorial for beginners"

  1. Dunham’s Sports is the most prominent sports good chain in the Midwest. Dunham’s started its first venture in West Bloomfield in 1973. Dunham’s Bait and Tackle was its name and it was a small shop. In a few years, Dunham’s emerged as a great sporting brand and spread to 23 states. They have 235 stores available from Wyoming to Maryland. You can find a full line of traditional Sporting goods, athletic equipment, active apparel, sportswear and footwear. dunhams coupon

    ReplyDelete