Hi, welcome back to Easy Learn
Today, We will learn about the architecture of selenium web-driver, It is nothing but learning how our selenium works internally.
- Selenium language bindings:- It is the language supported by the selenium, Test scripts are written in using these programming languages, The most common and popular used are Java and Python for automation scripting.
- Web drivers:- Web drivers are the web automation frameworks, which will allow the user to execute the automation scripts against the browsers.
- Web browser:- Web browser is a software application for accessing the information on the World Wide Web but commonly known as a browser.
- JSON Wire Protocol:- Our Selenium Web driver will JSON (JavaScript Object Notation) Wire Protocol is used to write an read the data on web, JSON wire protocol is widely used in World Wide Web , As it support Most common and popular used data structure like object and Array, Also It is easy to read and write data from JSON, and JSON serves the REST Web services
To Understand flow We need to write some sample script, Assuming as you all installed the Selenium web driver in your personal laptop, if your not installed please follow the previous blog for instruction Introduction to selenium
We are writing the Sample Selenium Script which will Open the Google chrome browser, Go to Easy learn page and Close the browser.
package testscripts;
import org.openqa.selenium.chrome.ChromeDriver;
public class DemoEasy {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "./driver/chromedriver.exe");
//Above line will set the path of web driver
ChromeDriver driver = new ChromeDriver();
//Creating the object for chrome driver
driver.get("https://easylearn29.blogspot.com");
//To open the
System.out.println("Easy learn 29 website is opened");
//To print output
driver.close();
// Close the webdriver
}
}
When above code is compiled, Compiler will find the path of WebDriver in the system because
the WebDriver are the like instructor to the browser and Our code is like instruction menu,
The path is set by using the Set property, Remember if you provide the path value wrong or set property code line is not written, Compiler throw the "java.lang.illegalstateexception"
Once path has been successfully set, Compiler will be create the object reference for Chrome driver, Using that object reference we can call and utilize the method in the Chrome driver class.
Here we are only using get () method there are many methods used commonly will be disscussed in future blogs
What is get () method?
Above method only accept the String data and return type is void, it will try to load the string data that has passed in chrome browser
NOTE: You can load the web page even using navigate () method
Next line of code will print the output in the console like printf in C program, at last Close () is the method it will exit WebDriver and clear driver instance data.
Here is an assignment, Write the script to load the Google page and Close the browser in Firefox browser
Hint: You may need geekodriver instance to load the page in Fire Fox browser
In the next blog, We will discuss about the different types of Web Driver method and different type of locators
No comments:
Post a Comment