As we all know, Software testing is a technique to test and compare the actual outcome with the expected outcome to validate the application functionality/Performance. To validate the functionality of apps, a tester can achieve this by Manual Testing or Automation Testing. Manual Testing as named, Tester has to check the whole testing like the functionality of application manually. He has to create reports, traceability matrix, test plans, etc. manually and the worst thing is he has to perform similar/same actions multiple times. On the other hand, Automation testing changed the way to do testing. You just need to write a test script and call multiple times or reuse the script to test another application.
The way the IT Industry is growing these days. Automation testing has brought a huge shift in software testing. There are so many automation testing tools available in the IT market. Selenium is one of the most infamous and highly-demanded tool. It is open-source that is designed to test the application. It comes in 2 different types:
- Selenium IDE
- Selenium Webdriver(support different programming libraries)
- Selenium Grid
As a beginner, one common question comes to our mind “Where and How to start learning? Or How to write the first test script in Selenium Webdriver?”
Before start learning or writing a simple test script, we need to check prerequisites or what skills we need which are as follows:
- Java Programming
- Basics of HTML5
- Basics of CSS & Javascript
- Hands-on experience on Eclipse IDE
- Import Selenium Jar files into Eclipse project
- And your curiosity
If you don’t have knowledge of Java programming. Just enroll in our Java for Automation Testing course. Besides Java programming, you need basic knowledge of HTML5, CSS & Javascript to understand webpages’ components. To learn about web page components, you can enroll in our following courses:
Okay, so we have seen what skills we need to write a test script. Now it is time to write a simple test script but what page can we test or where to start testing the application? The answer is the homepage where we can start testing because every domain like E-learning or E-commerce application has a homepage which is the gateway to enter.
Let’s write the steps to check the home page is opening.
- Create a Java project.
- Import Selenium Jar files into the project.
- Create a simple Java class OpenWithChrome with package details.
- Write statement into the main method to create an instance of Selenium WebDriver.
- Download chromedriver and configure the browser
- Navigate to URL.
- Check the status.
Let’s Automate Selenium Login with Java. Here are some important statements of the code.
- Create an instance of Selenium WebDriver
ChromeDriver driver=new ChromeDriver();
In order to launch the website, we need to set the webdriver instance with a chrome browser.
- Configure browser
Based on the needs, we need to set system properties to the path of the driver for the required browser.
Syntax:
System.setProperty("webdriver.chrome.driver","file path for driver path");
By default, the size of the chrome browser is minimized. To maximize, we need
To maximize the browser window.
Syntax:
driver.manage().window().maximize();
- Navigate to url.
To open the required site into the browser.
Syntax :
driver.get("https://www.itlearn360.com");
- To check if the site’s homepage is open, we need to check that code should not throw a runtime error. If it is not throwing any error it means the site’s home page opened successfully.
Below is the complete code of home page automation.
package seleniumpractice; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class OpenWithChrome { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "file path for driver path"); ChromeDriver driver=new ChromeDriver(); driver.get("https://www.itlearn360.com"); driver.manage().window().maximize(); System.out.println("website opened"); driver.close(); } }
To get more details or wants to learn & become an automation tester, Please visit the below URL:
https://www.itlearn360.com/courses/software-testing-academy/
ITlearn360 has launched a very affordable plan to become a QA Tester/ Automation Tester. You just need to pay $1 a day and learn various technologies like:
- Learn Java programming
- STLC
- Agile Methodology
- JIRA for Project Management
- DevOps
- Git
- Jenkins for Continuous Delivery
- Testing Approaches
- Hybrid Test Framework
AND MANY MORE TECHNOLOGIES
To get more details, please visit
Happy Learning 😀