[Webtest] Browser support in Webtest/HTMLUnit
Marc Guillemot
webtest@lists.canoo.com
Mon, 09 May 2005 09:24:18 +0200
Hi,
the problem comes from htmlunit's JS implementation of the navigator object. This has been fixed
in htmlunit but the new lib has not yet been shipped with webtest.
Marc.
nimeshm@mastek.com wrote:
> Hi,
>
> Has anyone ran their scripts simulating Netscape as a browser?
>
> When I am trying to playback the script even for Netscape as a browser it still shows me that the browser is IE!
>
> I have a sample HTML file whose source is
> <html>
> <head>
> <SCRIPT LANGUAGE="JavaScript">
> function openWindow()
> {
> alert("Browser userAgent = " + navigator.userAgent);
> if(document.layers)
> {
> alert("Netscape browser");
> }
> else if(document.all)
> {
> alert("Internet Explorer");
> }
> }
> </SCRIPT>
> </head>
> <body>
> <FORM METHOD="POST" name="frmName">
> <input type="button" name="hi" value = "ClickMe" onclick="openWindow();">
> </FORM>
> </body>
> </html>
>
> Webtest script as follows.
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <project name="CheckBrowser" basedir="." default="main">
> <property name="webtest.home" value="${basedir}"/>
> <taskdef file="${webtest.home}/webtestTaskdefs.properties">
> <classpath>
> <fileset dir="${webtest.home}" includes="**/lib/*.jar"/>
> <fileset dir="${webtest.home}/lib" includes="/*.jar"/>
> <fileset dir="${webtest.home}/lib" includes="**/optional/*.jar"/>
> <fileset dir="${webtest.home}/lib" includes="**/build/*.jar"/>
> </classpath>
> </taskdef>
> <target name="main">
> <testSpec name="webtest test number 1">
> <config
> host="localhost"
> port="8080"
> protocol="http"
> basepath="/"
> summary="true"
> saveresponse="true"
> resultpath="results"
> resultfile="TestResults.xml"
> >
> <header name="User-Agent" value="Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3"/>
> <!--<header name="User-Agent" value="4.0 (compatible; MSIE 6.0; Windows 98)"/>-->
>
> </config>
> <steps>
> <invoke url="CheckBrowser.html" stepid=""/>
> <clickbutton label="ClickMe" stepid="Click the button" />
> </steps>
> </testSpec>
>
> </target>
> </project>
>
> When I run the above script in debug mode I get Warnings for two alert messages. Namely:
> [testSpec] WARN (com.gargoylesoftware.htmlunit.javascript.host.Window) - window.alert("Browser userAgent = Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)") no alert handler installed
> [testSpec] WARN (com.gargoylesoftware.htmlunit.javascript.host.Window) - window.alert("Internet Explorer") no alert handler installed
>
> The second alert message is always window.alert("Internet Explorer") even if I have set the User-Agent in the header as Netscape. In the debug mode it shows that the browser being used is Netscape.
>
> Can someone throw some light on this.
>
> I am using release 1.7 (build 6xx) and htmlunit is of 03 Jan 2005.
>
> My aim is to have one script and make it run as if the browser is IE and also Netscape. So that with the help of the scripts I can easily check cross browser compatibility of my application. Any solutions or ideas on this?
>
> Thanks.
> Regards,
> - Nimesh
>
>
> MASTEK
> "Making a valuable difference"
> Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.
> In the US, we're called MAJESCO
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from all computers.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>