Selenium Webdriver Appium Complete TutorialSelenium Webdriver Appium Complete Tutorial
Automation Testing
  • Tools
    • Selenium
      • Selenium Java Tutorial
      • Selenium C# Tutorial
    • Appium
      • Appium Java Tutorial
      • Appium C#Tutorial
    • Katalon
  • Trainings
  • TestNG
  • Reports
    • Extent Reports
      • Extent Reports – Java
      • Extent Reports – Java -Version3
      • Extent Reports – C#
    • Vigo Reports
    • AT Excel Report
  • Excel
    • Apache POI – Java
    • Excel With C#
  • Interview Questions
    • Selenium Interview Questions
    • Java Interview Questions
    • C# Interview Questions
  • Demo Site
  • Practice Site
  • More…
    • AutoIt
    • Sikuli
    • Robot Class
    • File Upload
    • ScreenShot
      • AShot
      • ShutterBug
  • About
December 11, 2016

Handling Basic Elements in Selenium





Handling basic elements in Selenium will discuss about how we can interact with the elements which we will use very frequently on any applications. In this video we will understand the concept of WebElement also; as we will call all the elements which are there on the web page are web elements.

In this, we will see how we will handle the below elements which are frequent in any application:

  1. Textbox
  2. Button
  3. Radio Button
  4. CheckBox etc…

To achieve this we will write one simple sample program to automate the AUT(Application Under Test). Here we will see the process in step by step. For this we need to follow the below steps:

  1. Install/Download any IDE(to write the code)
  2. Download and Add Selenium Jar files
  3. Create a Java Project In IDE
  4. Create a Class under the Project
  5. Write Sample Code
    • Open Browser
    • Navigate to the application URL
    • Capture the locators of the Web Element which are there on the application
    • Write the code for automating the functionality
    • Execute the program.





Below is the Sample Program:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SampleProgram
{
   public static void main(String[] args) throws InterruptedException
   {
       System.setProperty("webdriver.gecko.driver", "Path of gecko driver");
       WebDriver driver = new FirefoxDriver();
       driver.get("http://demo.automationtesting.in/Register.html");
       driver.findElement(By.cssSelector("input[placeholder='First Name']")).sendKeys("Krishna");
       driver.findElement(By.cssSelector("input[placeholder='Last Name']")).sendKeys("Kumar");
       driver.findElement(By.cssSelector("#submitbtn")).click();
       Thread.sleep(5000);
       driver.quit();
   }
}

In the above program we are handling some of the basic elements (i.e. Textbox and Button).  For each and every webelement it is mandatory to get the locator and use the same in the code to identify that element.

We have separate API/methods to handle different types of elements. To handle textbox we have separate method and to handle the button we have separate methods. Same way we have different API to handle different web elements. We need to understand the element before interacting with it. And the selenium simulates the human interactions means how you interact with the application manually almost same way selenium also interacts with the application.

Please watch the YouTube video for this blog for better understanding.



Share this post: on Twitter on Facebook on Google+

Useful Tools and Plugins in Selenium TestNG Introduction

Related Posts

TAKING WEB ELEMENT SCREENSHOT IN SELENIUM

Selenium - Java

How to Capture WebElement Screenshot in Selenium Webdriver using selenium 4

avoid Switch to window

Selenium - Java

How to Avoid Switch To Window in Selenium WebDriver

webdrivermanager

Selenium - Java

No More Driver EXE files for Selenium Execution – Instead Use WebDriverManager

HANDLE TEXTBOXES IN SELENIUM

Selenium - Java

Handling Textboxes in Selenium

JAVASCRIPTEXECUTOR IN SELENIUM

Selenium - Java

JavaScriptExecutor in Selenium

ELEMENT NOT VISIBLE EXCEPTION

Selenium - C#, Selenium - Java

Selenium ElementNotVisibleException

NOSUCHWINDOW EXCEPTIONS

Selenium - C#, Selenium - Java

Selenium NoSuchWindowException

NOSUCHFRAME EXCEPTIONS

Selenium - C#, Selenium - Java

Selenium NoSuchFrameException

NOSUCHELEMENT EXCEPTION

Selenium - C#, Selenium - Java

Selenium NoSuchElementException

SELENIUM WEBDRIVER EXCEPTIONS

Selenium - C#, Selenium - Java

Selenium WebDriver Exceptions

Newsletter

Recent Posts

  • TAKING WEB ELEMENT SCREENSHOT IN SELENIUMHow to Capture WebElement Screenshot in Selenium Webdriver using selenium 4
    December 15, 2019
  • How To SWAP Two Numbers in Java Without using Temp VariableHow to SWAP Two Numbers in Java Without Temp variable or Without Third variable
    December 8, 2019
  • How to Swap Two Numbers in Java with Temp VariableHow to SWAP Two Numbers in Java using Temp Variable
    December 1, 2019
  • How to Read Properties file in JavaHow to Read Data From Properties File in Java
    November 27, 2019
  • Compare two arrays in java with out inbuilt functionsHow to Compare Two Arrays in Java without built-in functions
    November 16, 2019
© Selenium Webdriver Appium Complete Tutorial 2023