Oct 25, 2019 Please refer to previous posts on locating elements using various strategies available in WebDriver in case you missed them. Let us see why this process is tricky with an example scenario. Example: Navigate to www.amazon.com, and click on the ‘kindle’ image shown on the home page (as on the day this post was created). Upon clicking the.
This tutorial will explain how to run the Selenium WebDriver with Java
Selenium is a powerful framework for testing web applications. With Selenium you can automate the browsing, clicking and submitting forms on web pages. Once you have made changes to your web app it is always a good idea to run it trough some manual and automated tests and verify that everything is working properly. This tutorial will show you how to write your testing scripts with Java programming language. I assume you already have some experience with Java. If not read our Java Beginner tutorials first.
Selenium Maven Build
If you are using Maven to build your project use following dependency in your .pom file
Selenium .jar Files
If you prefer the old-fashioned way you have to download the required .jars from Selenium web-site.
1. Go to Selenium download page
2. Download the java 2.xx zip file
3. Copy selenium-java-2.44.0.jar and all the jars from libs folder to your project
Selenium Console Example
This is a basic Selenium java example. It uses the default HtmlUnitDriver to extract the page title in console-like style.
Selenium Firefox Example
In many cases you will need Selenium to work with dynamically created elements. For this you will need a browser window like this from Firefox or Google Chrome.
Following example needs Firefox web browser installed on the default location.
1. Selenium will open a separate Firefox window and go to https://javatutorial.net
2. Look on the search button (the magnifier glass) on top of this page, yes – the top of the page you are currently reading ? Selenium will move the cursor to this position to make the search field visible
3. It will type the search term “java” and submit the form
4. Wait for 5 seconds before closing the browser window
Selenium Chrome Example
To make Selenium use Google Chrome as browser you will need to download and run the standalone Chrome WebDriver.
1. Download Chrome Web Driver for your OS, the archive contains a single executable
2. Start the executable – it will run a local server on port 9515
3. Create the WebDriver like this in your code:
And here is the same example as above done with Chrome web driver:
Related Tutorials
Java Eclipse Tutorial
In this tutorial I will show you how to simplify your Java programming with Eclipse IDE. What is Eclipse IDE IDE stands for Integrated Development Environment.…
Java WebSockets Tutorial with Glassfish and Jetty
In this tutorial I will show you how to make a simple chat application running on Glassfish 4. I will use two APIs to accomplish…
Simple Java Example
This tutorial will explain how to download and install Java on your computer. We will also show you how simple it is to write a…
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms.
Key Highlights of Selenium Tutorial PDF are
1000+ pages
eBook Designed for beginners
Beautifully annotated screenshots
You will get lifetime access
Inside this PDF
Introduction to Selenium
Install Selenium IDE and FireBug
Introduction to Selenium IDE
Creating your First Selenium IDE script
How to use Locators in Selenium IDE
How to enhance a script using Selenium IDE
Store Variables, Echo, Alert, PopUp handling in Selenium IDE
Introduction to WebDriver & Comparison with Selenium RC
Guide to install Selenium WebDriver
Creating your First Script in Webdriver
Accessing Forms in Webdriver
How to Select Option from DropDown using Selenium Webdriver
Accessing Links & Tables using Selenium Webdriver
Keyboard & Mouse Event using Action Class in Selenium Webdriver
How to Upload & Download a File using Selenium Webdriver
XPath in Selenium: Complete Guide
How TestNG makes Selenium tests easier
Handling Date Time Picker using Selenium
Alert & Popup handling in Selenium
Handling Dynamic Web Tables Using Selenium WebDriver
Using Contains, Sibling, Ancestor to Find Element in Selenium
Implicit & Explicit Waits in Selenium
Parameterization using XML and DataProviders: Selenium
All About Excel in Selenium: POI & JXL
Page Object Model (POM) & Page Factory in Selenium: Ultimate Guide
Introduction to Selenium Grid
Maven & Jenkins with Selenium: Complete Tutorial
Creating Keyword & Hybrid Frameworks with Selenium
Database Testing using Selenium: Step by Step Guide
Handling Iframes in Selenium
Cross Browser Testing using Selenium
PDF , Emails and Screenshot of Test Reports in Selenium
How to Take Screenshot in Selenium WebDriver
Sessions, Parallel run and Dependency in Selenium
Tutorial on Log4j and LogExpert with Selenium
Selenium with HTMLUnit Driver & PhantomJS
Using Robot API with Selenium
How to use AutoIT with Selenium
Desired Capabilities in Selenium
SSL Certificate Error Handling in Selenium
Handling Ajax call in Selenium Webdriver
Listeners and their use in Selenium WebDriver
Execute JavaScript based code using Selenium Webdriver
Using Selenium with Python
How to use intelliJ & Selenium Webdriver
Test Case Priority in TestNG
TestNG: Execute multiple test suites
Introduction to TestNG Groups
Verify Tooltip Using Selenium WebDriver
Flash Testing with Selenium
How to Find Broken links using Selenium Webdriver
Selenium Core Extensions
Using Apache Ant with Selenium
Using Selenium with Github
Handling Cookies in Selenium WebDriver
Using SoapUI with Selenium
XSLT Report in Selenium
Firefox Profile - Selenium WebDriver
Breakpoints and Startpoints in Selenium
Top 100 Selenium Interview Questions & Answers
Using Cucumber with Selenium
Drag and Drop action in Selenium
Selenium C# Webdriver Tutorial for Beginners
Creating Object Repository in Selenium WebDriver
Scroll UP or Down a page in Selenium Webdriver
File Upload using Sikuli in Selenium Webdriver
Gecko (Marionette) Driver Selenium: Download, Install, Use with Firefox