Showing posts with label Chrome. Show all posts
Showing posts with label Chrome. Show all posts

October 30, 2015

Run selenium tests in Chrome and IE browser

October 30, 2015 27
How to run the selenium test scripts in Chrome/IE browser ?

To run the selenium test cases in Chrome/IE browser is necessary and need of today's web world as Chrome being the one of the best and most widely used web browser.

Selenium by default supports only Mozilla Firefox . 

To run your tests in Chrome browser please do the following set-up.

1. Download chrome browser related jar file from here.

2. Set the System configuration by adding the following code.

System.setProperty("webdriver.chrome.driver", "Path to chrome related jar file downloaded in step 1");
WebDriver driver = new ChromeDriver();

To run the test in Internet explorer.

1. Download IE browser related jar file from here.

2. Set the System configuration by adding the following code.

System.setProperty("webdriver.ie.driver", "C:\\Users\\ajain5\\Downloads\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();



October 20, 2015

Handling Basic Authentication Using Webdriver

October 20, 2015 20
Here is post which explains you how to handle basic authentication.

Problem:

Some of the applications that are secured with Basic Authentication. If you want to access those applications first you need to pass credentials. Those applications will launch a system level pop-up which cant not be handled by selenium.

IF you access below url it will ask for authentication.

http://the-internet.herokuapp.com/basic_auth



Solution:

By specifying userName and password in URL when accessing the page we can avoid system level dialog. This approach will work for HTTP and HTTPS pages.


Reference: http://elementalselenium.com/tips/13-work-with-basic-auth

Example:

December 17, 2012

Run Webdriver script in Google Chrome

December 17, 2012 2
This post explains you how to run your webdriver script in google chrome..

Firefox Browser:
driver=new FirefoxDriver();  --it will work and will launch your firefox browser,

Google Chrome:

driver= new Chromedriver() --- it will throw an error.

Error:


FAILED CONFIGURATION: @BeforeClass beforeClass
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list

To over come this we need to download the chrome driver.exe and we have to specify the apth of chrome driver in the script

Download path:
http://code.google.com/p/chromedriver/downloads/list

take the latest exe file. see the below image




save the chrome driver in a folder and you need to specify the path of driver in your webdriver script.

Below is the Sample code:


package testng;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class ChromedriverTest {

public WebDriver driver;
  @BeforeClass
  public void beforeClass() {
// Create chrome driver instance...
 System.setProperty("webdriver.chrome.driver", "C:\\xxx\\Jar\\chromedriver.exe");
 driver=new ChromeDriver();
  }


  @Test
  public void testChromedriverTest() throws Exception {
 driver.navigate().to("http://bing.com");
 Thread.sleep(5000);
  }

  @AfterClass
  public void afterClass() {
 driver.quit();
  }

}


Use the above code your script will run in google chrome.