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>