Tuesday, September 27, 2016

MultiBrowser Testing

MultiBrowser Testing

Users can execute scripts in multiple browser simultaneously. For demo purposes, we will make use of the same scenario that we had taken for Selenium Grid. In selenium Grid example, we had executed scripts remotely, where as we will execute the scripts locally.

Even for this we should ensure that we have appropriate drivers downloaded. Please refer to Selenium Grid Chapter for downloading IE and Chrome Drivers.

Example

We will perform percent calculator in all browsers simulataneously for demo purposes.

package TestNG; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.testng.annotations.*; public class TestNGClass { private WebDriver driver; private String URL = "http://www.calculator.net"; @Parameters("browser") @BeforeTest public void launchapp(String browser) { if (browser.equalsIgnoreCase("firefox")) { System.out.println(" Executing on FireFox"); driver = new FirefoxDriver(); driver.get(URL); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.manage().window().maximize(); } else if (browser.equalsIgnoreCase("chrome")) { System.out.println(" Executing on CHROME"); System.out.println("Executing on IE"); System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe"); driver = new ChromeDriver(); driver.get(URL); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.manage().window().maximize(); } else if (browser.equalsIgnoreCase("ie")) { System.out.println("Executing on IE"); System.setProperty("webdriver.ie.driver", "D:\\IEDriverServer.exe"); driver = new InternetExplorerDriver(); driver.get(URL); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.manage().window().maximize(); } else { throw new IllegalArgumentException("The Browser Type is Undefined"); } } @Test public void calculatepercent() { driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a")).click(); // Click on Math Calculators driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")).click(); // Click on Percent Calculators driver.findElement(By.id("cpar1")).sendKeys("10"); // Enter value 10 in the first number of the percent Calculator driver.findElement(By.id("cpar2")).sendKeys("50"); // Enter value 50 in the second number of the percent Calculator driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")).click(); // Click Calculate Button String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")).getText(); // Get the Result Text based on its xpath System.out.println(" The Result is " + result); //Print a Log In message to the screen if(result.equals("5")) { System.out.println(" The Result is Pass"); } else { System.out.println(" The Result is Fail"); } } @AfterTest public void closeBrowser() { driver.close(); } }

Create an XML which will help us in parameterizing Browser name and don't forget to mention parallel="tests" inorder to execute in all browsers simultaneously.

Execute the script by performing right click on the XML file and select 'Run As' >> 'TestNG' Suite as shown below.

Output

All Browser would be launched parallely and the result would be printed on console.

Note : For us to execute on IE successfully ensure that the check box 'Enable Protected Mode' under security Tab of 'IE Option' is either checked or Unchecked across all zones.

TestNG results can be viewed in HTML format for detailed analysis.

Selenium Exception Handling

Selenium Exception Handling

Exception Handling

When we are developing tests, we should ensure that the scripts can continue its execution even if the test fails. An unexpected exception would be thrown if the worst case scenarios are not handled properly.

If an exception occurs due to element not found or if the expected result doesn't match with actuals, we should catch that exception and end the test in a Logical way that the script itself terminating abruptly.

Syntax

The actual code should be placed in try block and the action after exception should be placed in catch block. Please Note 'finally' block would be no matter if the script had thrown exception or NOT.

try { //Perform Action } catch(ExceptionType1 exp1) { //Catch block 1 } catch(ExceptionType2 exp2) { //Catch block 2 } catch(ExceptionType3 exp3) { //Catch block 3 } finally { //The finally block always executes. }

Example

If an element not found(because of any good reason), we should ensure that we step out of the function smoothly. So always need to have try-catch block if we want to do the same.

public static WebElement lnk_percent_calc(WebDriver driver)throws Exception { try { element = driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")); return element; } catch (Exception e1) { // Add a message to your Log File to capture the error Logger.error("Link is not found."); // Take a screenshot which will be helpful for analysis. File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot, new File("D:\\framework\\screenshots.jpg")); throw(e1); } }

Log4j Logging

Log4j Logging

Log4j is an audit logging framework that gives information about what has happened during execution. It has following advantages:

Enables us to understand the the application run.

log output can be saved that can be analyzed later.

Helps in debugging, in case of test automation failures

Can also be used for auditing purposes to look at the application's health.

Components

1. Instance of Logger class.

2. Log level methods used for logging the messages as one of the following

error

warn

info

debug

log

Example

Let us use the same percent calculator for this demo.

Step 1 : Download log4j JAR file from https://logging.apache.org/log4j/1.2/download.html and download the Zipped format of the JAR file.

Step 2 : Create 'New Java Project' by navigating to File Menu.

Step 3 : Enter the name of the project as 'log4j_demo' and click 'Next'

Step 4 : Click Add External Jar and add 'Log4j-1.2.17.jar'

Step 5 : Click Add External Jar and add Selenium WebDriver Libraries.

Step 6 : Click Add External Jar and add Selenium WebDriver JAR's located in Libs folder.

Step 7 : Add a New XML file using which we can specify the Log4j Properties.

Step 8 : Enter the Logfile name as 'Log4j.xml'.

Step 9 : Final folder structure is shown below.

Step 10 : Now add the properties of Log4j which would be picked up during execution.

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <appender name="fileAppender" class="org.apache.log4j.FileAppender"> <param name="Threshold" value="INFO" /> <param name="File" value="percent_calculator.log"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%c] (%t:%x) %m%n" /> </layout> </appender> <root> <level value="INFO"/> <appender-ref ref="fileAppender"/> </root> </log4j:configuration>

Step 11 : Now for demo purpose, we will incorporate log4j in the same test that we have been performing(percent calculator). Add a class file with 'Main' function

package log4j_demo; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator; import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; public class log4j_demo { static final Logger logger = LogManager.getLogger(log4j_demo.class.getName()); public static void main(String[] args) { DOMConfigurator.configure("log4j.xml"); logger.info("# # # # # # # # # # # # # # # # # # # # # # # # # # # "); logger.info("TEST Has Started"); WebDriver driver = new FirefoxDriver(); //Puts a Implicit wait, Will wait for 10 seconds before throwing exception driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); //Launch website driver.navigate().to("http://www.calculator.net/"); logger.info("Open Calc Application"); //Maximize the browser driver.manage().window().maximize(); // Click on Math Calculators driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a")).click(); logger.info("Clicked Math Calculator Link"); // Click on Percent Calculators driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")).click(); logger.info("Clicked Percent Calculator Link"); // Enter value 10 in the first number of the percent Calculator driver.findElement(By.id("cpar1")).sendKeys("10"); logger.info("Entered Value into First Text Box"); // Enter value 50 in the second number of the percent Calculator driver.findElement(By.id("cpar2")).sendKeys("50"); logger.info("Entered Value into Second Text Box"); // Click Calculate Button driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")).click(); logger.info("Click Calculate Button"); // Get the Result Text based on its xpath String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")).getText(); logger.info("Get Text Value"); //Print a Log In message to the screen logger.info(" The Result is " + result); if(result.equals("5")) { logger.info("The Result is Pass"); } else { logger.error("TEST FAILED. NEEDS INVESTIGATION"); } logger.info("# # # # # # # # # # # # # # # # # # # # # # # # # # # "); //Close the Browser. driver.close(); } }

Execution

Upon execution the log file is created on the root folder as shown below. You CANNOT locate the file in Eclipse. 

Data Driven using Excel

Data Driven using Excel

When designing tests, parameterizing the tests is inevitable. We will make use of Apache POI - Excel JAR's to achieve the same. It helps us to read and write into excel.

Download JAR

Step 1 : Navigate to the URL - http://poi.apache.org/download.html and download the ZIP format.

Step 2 : Click on the Mirror Link to download the JAR's.

Step 3 : Unzip the contents to a folder.

Step 4 : Unzipped contents would be displayed as shown below.

Step 5 : Now create a New project and add all the 'External JARs' under 'poi-3.10.FINAL' folder.

Step 6 : Now add all the 'External JARs' under 'ooxml-lib' folder.

Step 7 : Now add all the 'External JARs' under 'lib' folder.

Step 8 : The Added JAR is displayed as shown below.

Step 9 : The Package Explorer is displayed as shown below. Apart from that add 'WebDriver' related JAR's

Parameterization

For Demo purposes, we will parameterize the percent calculator test.

Step 1 : We will parameterize all the inputs required for percent calculator using excel. The designed excel is shown below.

Step 2 : Now we will execute all percent calculator for all the specified parameters.

Step 3 : Let us create generic methods to access the excel file using the imported JARS. These methods helps us to get a particular cell data or to set a particular cell data etc.

import java.io.*; import org.apache.poi.xssf.usermodel.*; public class excelutils { private XSSFSheet ExcelWSheet; private XSSFWorkbook ExcelWBook; //Constructor to connect to the Excel with sheetname and Path public excelutils(String Path, String SheetName) throws Exception { try { // Open the Excel file FileInputStream ExcelFile = new FileInputStream(Path); // Access the required test data sheet ExcelWBook = new XSSFWorkbook(ExcelFile); ExcelWSheet = ExcelWBook.getSheet(SheetName); } catch (Exception e) { throw (e); } } //This method is to set the rowcount of the excel. public int excel_get_rows() throws Exception { try { return ExcelWSheet.getPhysicalNumberOfRows(); } catch (Exception e) { throw (e); } } //This method to get the data and get the value as strings. public String getCellDataasstring(int RowNum, int ColNum) throws Exception { try { String CellData = ExcelWSheet.getRow(RowNum).getCell(ColNum).getStringCellValue(); System.out.println("The value of CellData " + CellData); return CellData; } catch (Exception e) { return "Errors in Getting Cell Data"; } } //This method to get the data and get the value as number. public double getCellDataasnumber(int RowNum, int ColNum) throws Exception { try { double CellData = ExcelWSheet.getRow(RowNum).getCell(ColNum).getNumericCellValue(); System.out.println("The value of CellData " + CellData); return CellData; } catch (Exception e) { return 000.00; } } }

Step 4 : Now add a main method which will access the excel methods that we have developed.

import java.io.*; import org.apache.poi.xssf.usermodel.*; public class excelutils { private XSSFSheet ExcelWSheet; private XSSFWorkbook ExcelWBook; //Constructor to connect to the Excel with sheetname and Path public excelutils(String Path, String SheetName) throws Exception { try { // Open the Excel file FileInputStream ExcelFile = new FileInputStream(Path); // Access the required test data sheet ExcelWBook = new XSSFWorkbook(ExcelFile); ExcelWSheet = ExcelWBook.getSheet(SheetName); } catch (Exception e) { throw (e); } } //This method is to set the rowcount of the excel. public int excel_get_rows() throws Exception { try { return ExcelWSheet.getPhysicalNumberOfRows(); } catch (Exception e) { throw (e); } } //This method to get the data and get the value as strings. public String getCellDataasstring(int RowNum, int ColNum) throws Exception { try { String CellData = ExcelWSheet.getRow(RowNum).getCell(ColNum).getStringCellValue(); //Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum); //String CellData = Cell.getStringCellValue(); System.out.println("The value of CellData " + CellData); return CellData; } catch (Exception e) { return "Errors in Getting Cell Data"; } } //This method to get the data and get the value as number. public double getCellDataasnumber(int RowNum, int ColNum) throws Exception { try { double CellData = ExcelWSheet.getRow(RowNum).getCell(ColNum).getNumericCellValue(); //Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum); //String CellData = Cell.getStringCellValue(); System.out.println("The value of CellData " + CellData); return CellData; } catch (Exception e) { return 000.00; } } }

Selenium Page Object Model

Selenium Page Object Model

As we all know that Selenium acts on webelements with the help of their properties such ID, name, Xpath etc. Unlike QTP which has an inbuilt object repository(OR), Selenium has NOT got an inbuilt OR.

Hence we need to build OR which should also be maintainable and accessible on demand. Page Object Model(POM) is a popular design pattern to create an Object Repository in which each one of those webelements properties are created using a class file.

Advantages

Page Object model is an implementation where test objects and functions are seperated from each other and thereby keeping the code clean.

The Objects are kept independent of test script. An object can be accessed by one or more test scripts, hence POM helps us to create object once and use it multiple times.

Since objects are created once, it is easy to access as well as easy to update a particular property of an object.

POM Flow Diagram

Objects are created for Each one of the pages and methods are developed exclusively to access to those objects. Let us make use of http://calculator.net for understanding the same.

There are various calculators associated with it and each one of those objects in a particular page is created in a seperate class file as static methods and they all are accessed in 'tests' class file in which a static method would be accessing the objects.

Example

Let us understand it by performing a implementing POM for percent calculator test.

Step 1 : Create a simple class(page_objects_perc_calc.java) file within a package and create methods for each one of those object identifiers as shown below.

package PageObject; import org.openqa.selenium.*; public class page_objects_perc_calc { private static WebElement element = null; // Math Calc Link public static WebElement lnk_math_calc(WebDriver driver) { element = driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a")); return element; } // Percentage Calc Link public static WebElement lnk_percent_calc(WebDriver driver) { element = driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")); return element; } // Number 1 Text Box public static WebElement txt_num_1(WebDriver driver) { element = driver.findElement(By.id("cpar1")); return element; } // Number 2 Text Box public static WebElement txt_num_2(WebDriver driver) { element = driver.findElement(By.id("cpar2")); return element; } // Calculate Button public static WebElement btn_calc(WebDriver driver) { element = driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")); return element; } // Result public static WebElement web_result(WebDriver driver) { element = driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")); return element; } }

Step 2 : Create a class with main and import the package and create methods for each one of those object identifiers as shown below.

package PageObject; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class percent_calculator { private static WebDriver driver = null; public static void main(String[] args) { driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("http://www.calculator.net"); // Use page Object library now page_objects_perc_calc.lnk_math_calc(driver).click(); page_objects_perc_calc.lnk_percent_calc(driver).click(); page_objects_perc_calc.txt_num_1(driver).clear(); page_objects_perc_calc.txt_num_1(driver).sendKeys("10"); page_objects_perc_calc.txt_num_2(driver).clear(); page_objects_perc_calc.txt_num_2(driver).sendKeys("50"); page_objects_perc_calc.btn_calc(driver).click(); String result = page_objects_perc_calc.web_result(driver).getText(); if(result.equals("5")) { System.out.println(" The Result is Pass"); } else { System.out.println(" The Result is Fail"); } driver.close(); } }

Output

The test is executed and the result is printed on console. Below is the snapshot of the same.

Selenium - Locators

Selenium Locators

Locating elements in Selenium WebDriver is performed with the help of findElement() and findElements() methods provided by WebDriver and WebElement class.

The findElement() method returns a WebElement object based on a specified search criteria or ends up throwing an exception if it does not find any element matching the search criteria.

The findElements() method returns a list of WebElements matching the search criteria. If no elements are found, it returns an empty list.

The Below table gives the java syntax for locating elements in selenium Webdriver.

MethodSyntaxDescriptionBy IDdriver.findElement(By.id(<element ID>))Locates an element the using ID attributeBy namedriver.findElement(By.name(<element name>))Locates an element using the Name attributeBy class namedriver.findElement(By.className(<element class>))Locates an element using the Class attributeBy tag namedriver.findElement(By.tagName(<htmltagname>))Locates an element using the HTML tagBy link textdriver.findElement(By.linkText(<linktext>))Locates link using link textBy partial link textdriver.findElement(By.partialLinkText(<linktext>))Locates link using link's partial textBy CSSdriver.findElement(By.cssSelector(<css selector>))Locates element using the CSS selectorBy XPathdriver.findElement(By.xpath(<xpath>))Locates element using XPath query

Locators Usage

Now let us understand the practical usage of each one of those locators methods with the help of http://www.calculator.net

1. By Id : The Object is accessed with the help of ID. In this case, it is the ID of the text box. The Value is entered into the text using sendkeys method with the help of ID(cdensity).

driver.findElement(By.id("cdensity")).sendKeys("10");

2. By name : The Object is accessed with the help of name. In this case, it is the name of the text box. The Value is entered into the text using sendkeys method with the help of ID(cdensity).

driver.findElement(By.name("cdensity")).sendKeys("10");

3. By Class name : The Object is accessed with the help of Class Name. In this case, it is the Class name of the WebElement. The Value can be accessed with the help of gettext method.

List<WebElement> byclass = driver.findElements(By.className("smalltext smtb"));

4. By Tag name : The DOM Tag Name of the element and it is very easy to handle table with the help of this method. We can look at an example out of the demo app.

WebElement table = driver.findElement(By.id("calctable")); List<WebElement> row = table.findElements(By.tagName("tr")); int rowcount = row.size();

5. By Link Text : This methods helps us to find the link element with matching visible text.

driver.findElements(By.linkText("Volume")).click();

5. By partial link text: This methods helps us to Find the link element with partial matching visible text.

driver.findElements(By.partialLinkText("Volume")).click();

6. By CSS : The CSS is used as a method to identify the webobject, however NOT all browsers support CSS identification.

WebElement loginButton = driver.findElement(By.cssSelector("input.login"));

7. By Xpath : XML stands for XML path language, is a query language for selecting nodes from an XML document. The XPath language is based on a tree representation of an XML document and provides the ability to navigate around the tree by selecting nodes using a variety of criteria.

driver.findElement(By.xpath(".//*[@id='content']/table[1]/tbody/tr/td/table/tbody/tr[2]/td[1]/input")).sendkeys("100");

Selenium Webdriver

Selenium Webdriver

WebDriver is a tool for automating testing web application popularly known as Selenium 2.0. WebDriver uses a different underlying framework while Selenium Remote Control uses javascript Selenium-Core embedded within the browser which has got some limitations. Webdriver interacts directly with the browser without any intermediary unlike Selenium remote control which depends on a Server. It is used in the below context :

The developer community in Selenium strive hard to improve Selenium continuously and Integrating WebDriver with selenium is one among them.

Mult-browser testing including improved functionality for browsers not well-supported by Selenium Remote control (selenium 1.0)

Handling multiple frames, multiple browser windows, popups, and alerts.

Complex Page navigation.

Advanced user navigation such as Drag-and-drop.

AJAX-based UI elements

Architecture

Webdriver is best explained with a simple architecture diagram as shown below.

Selenium RC Vs WebDriver

Selenium RCSelenium WebDriverSelenium RC architecture is complicated as the server needs to be up and running before starting a test.WebDriver's architecture is simpler than Selenium RC as it controls the browser from the OS level.Selenium Server acts as a middle man between browser and selenese commandsWebDriver interacts directly to the browser and uses the browser's engine to control it.Selenium RC script execution is slower since it uses a Javascript to interact with RCWebDriver is faster as it interacts directly with browser.Selenium RC cannot support the headless as tt needs a real browser to work with.WebDriver can support the headless executionIts a simple and small APIComplex and a bit large API as compared to RCLess Object oriented APIPurely Object oriented APICannot test mobile ApplicationsCan test iPhone/Android applications

Scripting using Webdriver

Let us understand how to work with webdriver. For demo purposes, we would use http://www.calculator.net/. We will perform a "percent Calculator" which is located under "Math Calculator". We have already downloaded the required webdriver JAR's. Refer Environmental chapter for details.

Step 1 : Launch "Eclipse" from the Extracted Eclipse Folder.

Step 2 : Select the Workspace by clicking on 'Browse' Button.

Step 3 : Now Create 'New Project' from 'File' Menu.

Step 4 : Enter the Project Name and Click 'Next'.

Step 5 : Goto Libraries Tab and select all the JAR's that we have dowonloaded(Refer Environment Set up Chapter). Add reference to all JAR's of Selenium Webdriver Library folder and also selenium-java-2.42.2.jar and selenium-java-2.42.2-ids.jar

Step 6 : The Package is created as shown below.

Step 7 : Now let us create a 'Class' by performing right click on package and select 'New' >> 'Class'

Step 8 : Now name the class and make it as main Function

Step 9 : The class outline is shown as below.

Step 10 : Now it is time to code. The below Script is easier to understand as it explains clearly step by step in the embedded comments. Please take a look at "Locators" chapter to understand how to capture object properties.

import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; public class webdriverdemo { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); //Puts a Implicit wait, Will wait for 10 seconds before throwing exception driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); //Launch website driver.navigate().to("http://www.calculator.net/"); //Maximize the browser driver.manage().window().maximize(); // Click on Math Calculators driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a")).click(); // Click on Percent Calculators driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")).click(); // Enter value 10 in the first number of the percent Calculator driver.findElement(By.id("cpar1")).sendKeys("10"); // Enter value 50 in the second number of the percent Calculator driver.findElement(By.id("cpar2")).sendKeys("50"); // Click Calculate Button driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")).click(); // Get the Result Text based on its xpath String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")).getText(); //Print a Log In message to the screen System.out.println(" The Result is " + result); //Close the Browser. driver.close(); } }

Step 11 : The Output of the above script would be printed in Console.

Most used Commands

The below table lists the most used commands in Webdriver along with its syntax which will help us to develop Webdriver scripts seamlessly.

CommmandDescriptiondriver.get("URL")To Navigate to an applicationelement.sendKeys("inputtext")Enter some text into an input boxelement.clear()Clear the contents from the input boxselect.deselectAll()This will deselect all OPTIONs from the first SELECT on the pageselect.selectByVisibleText("some text")select the OPTION with the input specified by the user.driver.switchTo().window("windowName")Moving the focus from one window to anotherdriver.switchTo().frame("frameName")swing from frame to framedriver.switchTo().alert()Helps in handling alertsdriver.navigate().to("URL")Navigate to the URLdriver.navigate().forward()To Navigate forwarddriver.navigate().back()To Navigate backdriver.close()Closes the current Browser associated with the driverdriver.quit()Quits the driver and closes all the associated window of that driver.driver.refresh()Refreshes the current page.