2 messages in com.canoo.lists.webtest[Webtest] Re: RE: how to set the brow...
FromSent OnAttachments
object tester21 Dec 2004 18:17 
Marc Guillemot22 Dec 2004 00:47 
Subject:[Webtest] Re: RE: how to set the browser type for htmlunit? ( answers & more questions )
From:object tester (obje@yahoo.com.au)
Date:12/21/2004 06:17:43 PM
List:com.canoo.lists.webtest

I Follow up my question re how to set the browser type for htmlunit. (http://lists.canoo.com/pipermail/webtest/2004q4/002879.html)

Browsing the src for htmlunit and webtest I've now suss'd out based on the example in the documentation that to set the browser type you need to add in <header name="User-Agent" into config.xml.

e.g.

<config host="localhost" ... etc etc I've ommitted the rest of the config settings for brevity... showhtmlparseroutput="true"

<header name="User-Agent" value="Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0"/> </config>

the value for the user agent can be src'd from the constants defined in htmlunit src com/gargoylesoftware/htmlunit/BrowserVersion.java

qouting from htmlunit api

" If you wish to create a BrowserVersion for a browser that doesn't have a constant defined but aren't sure what values to pass into the constructor then point your browser at http://htmlunit.sourceforge.net/cgi-bin/browserVersion and the code will be generated for you. "

For webtest if you do not specify user agent in the config.xml then webtest passes onto htmlunit the default

FULL_FEATURED_BROWSER = new BrowserVersion( INTERNET_EXPLORER, "4.0 (compatible; MSIE 6.0b; Windows 98)", "Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)", "1.2");

this shows up in the log info as

[testSpec] strUserAgent [null] <custom System.out I added in my src ) [testSpec] (steps.Setup 51 ) Surfing with browser Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98) [testSpec] (steps.Setup 135 ) Configuring http headers (0 elts)

if you set User-Agent to be that for IE 6.0

<header name="User-Agent" value="4.0 (compatible; MSIE 6.0; Windows 98)"/>

this shows up in the log info as

[testSpec] strUserAgent [4.0 (compatible; MSIE 6.0; Windows 98)] [testSpec] (steps.Setup 71 ) baseBrowser = BrowserVersion.INTERNET_EXPLORER_6_0; [testSpec] (steps.Setup 77 ) Using browser version (Microsoft Internet Explorer, 4.0 (compatible; MSIE 6.0b; Windows 98), 4.0 (compatible; MSIE 6.0; Windows 98), 1.2). If the javascript support is not as expected, then it's time to go into the sources

in the src code of Setup.Java if User-Agent is not null (i.e set to a value in config.xml)

// as long as all browser properties are not configurable from the task, // use a "base" browser BrowserVersion baseBrowser = null; if (strUserAgent.indexOf(BrowserVersion.NETSCAPE) != -1) { baseBrowser = BrowserVersion.NETSCAPE_6_2_3; } else if (strUserAgent.indexOf("Gecko") != -1) { baseBrowser = BrowserVersion.MOZILLA_1_0; } else { baseBrowser = BrowserVersion.INTERNET_EXPLORER_6_0; }

if i use <header name="User-Agent" value="Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0"/>

which is the value for firefox 1.0 this show up in log info as

[testSpec] strUserAgent [Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0] [testSpec] (steps.Setup 66 ) baseBrowser = BrowserVersion.MOZILLA_1_0; [testSpec] (steps.Setup 77 ) Using browser version (Netscape, 5.0 (Windows; en-US), Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0, 1.2). If the javascript support is not as expected, then it's time to go into the sources

i.e it matches up the user agent as Mozilla 1.0 because of the gecko. I'm not an expert on the differences in browsers but the bottom line seems to be that webtest only supports the browser constants defined in BrowserVersion.java despite that htmlunit specifies you can define your own custom browser definition.

i.e if you want to simulate firefox but webtest/htmlunit is only simulating Mozilla 1.0 .....(http://www.mozillazine.org/)

"Mozilla 1.7.5 has been released. This latest update from the long-lived 1.7 branch contains a version of Gecko virtually identical to the one in Mozilla Firefox 1.0. New features not found in Mozilla 1.7.3 include the NPRuntime extensions to the Netscape Plugin API and undetectable document.all support. This release is called 1.7.5 as that's the underlying Mozilla version that Firefox 1.0 reports itself as being (1.7.4 was skipped in case that number was needed for a security update)."

qouting from htmlunit

" Specifying this BrowserVersion will change the user agent header that is sent up to the server and will change the behaviour of some of the javascript. Note that the version specific javascript behaviour still needs a lot of work. "

I notice that all the constants defined in BrowserVersion.java define javascript version 1.2. based on the qoute is it the user agent header that defines the js behaiviour or the js version?????

Marco

Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com