1

My web page only works in IE as it uses ActiveXObject in javascript. When coding a inhouse tool to test this web page, how do I specify browser type and version?

The Java codes are:

package main; 

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class Temp  {
    public static void main(String[] args) {
        // Create a new instance of the html unit driver
        // Notice that the remainder of the code relies on the interface, 
        // not the implementation.
        WebDriver driver = new HtmlUnitDriver();

        // And now use this to visit my web page
        driver.get("http://www.test.com:8000");
        
        // Find the text input element by its id
        driver.findElement(By.id("test")).click();
        driver.manage().timeouts().implicitlyWait(300,TimeUnit.SECONDS); 

        // Check the title of the page
        System.out.println("Result is: " + driver.findElement(By.id("demo")).getText());
        driver.quit();
    }
}

The web page is:

<html>
<body>
<script>
      function test() {    
  try {
  var variable_name;
   variable_name=new ActiveXObject("Microsoft.XMLHTTP");
   document.getElementById("demo").innerHTML = "ActiveXObject is created";
  }
  catch(err) {
   document.getElementById("demo").innerHTML = err.message;
  }
      }
    </script>
<input type="Button" id="test" value="Test" onClick='test()'>
<div id = "demo">blah</div>
</body>
</html>
Mosam Mehta
  • 1,658
  • 6
  • 25
  • 34
BayOtter
  • 209
  • 2
  • 9

2 Answers2

0

You need to use InternetExplorerDriver instead of HtmlUnitDriver. Check this page for detailed information.

Dmitry P.
  • 824
  • 5
  • 14
0

This is basically done at grid level, you need to setup a grid and run your tests again it.

Look at http://www.seleniumhq.org/docs/07_selenium_grid.jsp and search for "multiple versions of browser".

HTH

Jagdeep
  • 139
  • 3
  • 12