How to run Selenium script in IE Browser

How to run Selenium script in IE Browser post gives you clear explanation to run or execute selenium webdriver test scripts in Internet Explorer i.e IE browser.To run  Selenium script in IE Browser you require InternetExplorerDriver which it is a standalone server.In order to run your Selenium script you have to download Internet Explorer Driver to run your selenium scripts,just go to Selenium site and search for Internet Explorer Driver Server here you will find 32 bit version and 64 bit version to download as per your machine/Laptop.

Please follow below steps to run Selenium script in IE Browser and create test scripts in selenium webdriver. Please unzip the IEdriver and you will find IEDriverServer.exe file from zip file as below
Run selenium script in IE browser


Just you need to write this extra code to open or run your selenium test scripts in IE Browser

System.setProperty("webdriver.ie.driver", "F:/Java_Apps/IEdriverServer.exe");
driver = new InternetExplorerDriver();

Please find below example to run Selenium script in IE Browser ,i have used my blog i.e http://learn-selenium-automation-testing.blogspot.in/ to execute the test script with TestNG annotation,please read TestNG Tutorial.

package com.seleniumpractice.reports;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;


public class InternetExplorer {

 
 public WebDriver driver;
 String baseUrl = "http://learn-selenium-automation-testing.blogspot.in/"; 
 
 @BeforeTest
 public void openBrowser(){
  
 System.setProperty("webdriver.ie.driver", "F:/java_apps/IEdriverServer.exe"); 
 driver = new InternetExplorerDriver();
 driver.manage().window().maximize();
 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 
  
 }
 @Test
 public void openSite(){
  driver.get(baseUrl);
  //Verify whether exact page is open or not
  //Store page title in one String
  String actual_title = driver.getTitle();
  System.out.println("Page title of website"+actual_title);
  //If condition to verify page title
  String Expected_title = "Learn Selenium Automation Testing";
  
  if(actual_title.equals(Expected_title)){
System.out.println("Page title is matching with Expected Results - Test Case is PASS");
   
  }else{
System.out.println("Page title is not matching with expected results - Test Case is Fail");
  }
  
 }
 
 @AfterClass
 public void closeBrowser(){
  //Close open browser
  driver.close();
  System.out.println("IE Browser is closed");
 } 

}


Run the Test script as TestNG Test as Right click on Script - Run As - TestNG Test,you will see selenium test script execution in IE browser,most of the people facing speed issue in Internet explorer browser to open any website,in case selenium webdriver not finding page title in given time i.e 30 seconds,it will give you the error and it will fail the Test.

Test Results:

Once you execute the script it will display Test Results as below.

Started InternetExplorerDriver server (64-bit)
2.53.1.0
Listening on port 14471
Only local connections are allowed
Page title of websiteLearn Selenium Automation Testing
Page title is not matching with expected results - Test Case is Fail
PASSED: openSite

===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================

how to run selenium scripts in IE browser



I hope you got good information about how to run Selenium script in IE Browser with the help of IEDriver Server i.e internet explorer driver server,please provide your valuable comments and suggestions on this post.



No comments:

Post a Comment