public
Description: Webdriver binding for ColdFusion.
Homepage:
Clone URL: git://github.com/virtix/cfwebdriver.git
cfwebdriver / HtmlUnitDriver.cfc
100644 50 lines (34 sloc) 1.469 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<cfcomponent output="false" extends="WebDriver">
  <cfscript>
   /*
    to do: instead of maintaining a separate java class just to handle authentication,
    use reflectiion to the the protected method, getWebClient() to get the client
    and set it's authentication properties.
  */
  
  
    function init(){
   this.driverType = "HtmlUnit";
this.driver = createObject("java","org.openqa.selenium.htmlunit.HtmlUnitDriver").init();
      return this;
    }
    
    
    
    
   function isJavascriptEnabled(){
return this.driver.isJavascriptEnabled();
} // boolean
 
 
function setJavascriptEnabled(enable){
this.driver.setJavascriptEnabled(enable);
} //void
 
 
function authenticate(username, password, domain){
//To Do: NTLM Credentials ... more params, or separate method?
getWebClient().getCredentialsProvider().addCredentials(username,password);
}
 
 
function addNTLMCredentials(username, password, host, port, clientHot, domain){
//To Do: NTLM Credentials ... more params, or separate method?
getWebClient().getCredentialsProvider().addNTLMCredentials(username, password, host, port, clientHot, domain);
}
 
 
 
function getWebClient(){
      var getWebClientMethod = this.driver.getClass().getDeclaredMethod("getWebClient",arrayNew(1));
      var params = arrayNew(1);
      getWebClientMethod.setAccessible(true);
      return getWebClientMethod.invoke(this.driver,params);
    }
  </cfscript>
 
</cfcomponent>