Ticket #256 (closed enhancement: fixed)

Opened 3 months ago

Last modified 2 months ago

TestGen4Web Debugging Options

Reported by: fcohen Owned by:
Priority: blocker Milestone:
Version: 5.2 Keywords:
Cc:

Description (last modified by fcohen) (diff)

Hi William and Luis Carlos:

HTMLUnit offers some interesting and useful debug options. I'd like these to be incorporated into our TestGen4Web ScriptRunner.

Here's what I'm thinking:

DEBUG 1: HTMLUnit debugger logs requests/responses to the file system

<options>

<testgen4web DebuggingWebConnection?="true"/>

Internall this does:

connection = DebuggingWebConnection?(webClient.getWebConnection(), "mytest") webClient.setWebConnection(connection);

DEBUG 2: HTMLUnit debugger

<options>

<testgen4web HtmlUnitContextFactory?="true"/>

Internally this does: HtmlUnitContextFactory?.setDebuggerEnabled(1)

DEBUG 3: Log4J for HTMLUnit logging

<logs summaryreport="true" showsummary="false" step="true">

<log level="info" path="mylog.log" type="file"/>

Internally this does: rootLogger = LogManager?.getRootLogger(); rootLogger.setLevel( Level.toLevel("INFO") );

DEBUG 4:

TestGen4Web has a debug class (com.spike.tg4w.htmlunit.XmlTestResultImpl?) that I turned off when we were working on TM 5.0. com.spike.tg4w.htmlunit.HtmlUnitInterpreter? is in the original TestGen4Web code. It is very useful for debugging tests of Web applications. It saves the request/response interaction with the application host to a set of files.

It is completely useless during a load test. I wrote QuietTestResultImpl? as a load test friendly alternative. That is in place in the TM5 code base now.

Here is the syntax to enable the XmlTestResultImpl? class:

<options>

<testgen4web xmltestresultimpl="true"/>

The above 4 changes are for the langtype="TestGen4Web" script runner.

-Frank

from com.gargoylesoftware.htmlunit import WebClient
from com.gargoylesoftware.htmlunit.util import DebuggingWebConnection
from com.gargoylesoftware.htmlunit.javascript import HtmlUnitContextFactory
from org.apache.log4j import LogManager
from org.apache.log4j import Level

w1 = "https://dm-training.ias-trinium.com/"
w2 = "http://localhost:8080/BrewBizWeb/login.html"
w3 = "http://www.pushtotest.com"
w4 = "https://s02qaapp01/dispatchmanager/login.action"

print "starting"

rootLogger = LogManager.getRootLogger();
rootLogger.setLevel( Level.toLevel("INFO") );

HtmlUnitContextFactory.setDebuggerEnabled(1)

webClient = WebClient()

#from java.lang import System
#System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "trace")

connection = DebuggingWebConnection(webClient.getWebConnection(), "mytest")
webClient.setWebConnection(connection);


#webClient.setPrintContentOnFailingStatusCode(1)
#javascript

startPage = webClient.getPage( w4 )
print "getTitleText=", startPage.getTitleText()
print startPage

form = startPage.getFormByName("signon.action")
print "form=",form

username = form.getInputByName("username")
username.setValueAttribute("halle.bard");

psword = form.getInputByName("password")
psword.setValueAttribute("test");

#button = form.getButtonByValue("login")
#print "button=",button
#page2 = button.click()

page2 = form.submit( None )

print "page2 =", page2

'''
 // Get the first page
    final HtmlPage page1 = (HtmlPage) webClient.getPage("http://some_url");

    // Get the form that we are dealing with and within that form, 
    // find the submit button and the field that we want to change.
    final HtmlForm form = page1.getFormByName("myform");

    final HtmlSubmitInput button = (HtmlSubmitInput) form.getInputByName("submitbutton");
    final HtmlTextInput textField = (HtmlTextInput) form.getInputByName("userid");

    // Change the value of the text field
    textField.setValueAttribute("root");

    // Now submit the form by clicking the button and get back the second page.
    final HtmlPage page2 = (HtmlPage) button.click();
}
'''

print "done"


'''
WebClient client = new WebClient();
List collectedAlerts = new ArrayList();
client.setAlertHandler(new CollectingAlertHandler(collectedAlerts));
client.getPage(url);
'''

'''
http://training.interbox.com/ibx/
 
STO: ocsh/interbox
IMC: danl/interbox
 
Dispatch Manager is a bit different, has different UI technology components. Both software services 
have just been released into the Training environment, so I trust that you don?t perform anything ?heavy? 
and just wanted to get a sense of UI/page flow etc. Test case will follow.
 
https://dm-training.ias-trinium.com/
 
Originator: test.oa/dmtest
Recevier: test.ra/dmtest
'''

Attachments

stepworking.png (33.2 kB) - added by fcohen 2 months ago.
Screen shot of functional test showing failure in TestGen4Web

Change History

Changed 2 months ago by fcohen

Luis Carlos wrote:

If you use <log level="tg4w" path="mylog.log" type="file"/> The system will create a "tg4w log". The file will be saved in the log directory in the console.

An example of the log is:

INFO - Thread 0 [Wed Jun 25 11:02:41 CST 2008]: goto(http://www.google.co.cr/): Success[1047 sec]
INFO - Thread 0 [Wed Jun 25 11:02:41 CST 2008]: verify-title(Google): Success[0 sec]
INFO - Thread 0 [Wed Jun 25 11:02:41 CST 2008]: fill(español): Success[47 sec]
INFO - Thread 1 [Wed Jun 25 11:02:43 CST 2008]: goto(http://www.google.co.cr/): Success[2609 sec]
INFO - Thread 1 [Wed Jun 25 11:02:43 CST 2008]: verify-title(Google): Success[0 sec]
INFO - Thread 1 [Wed Jun 25 11:02:43 CST 2008]: fill(español): Success[0 sec]

Changed 2 months ago by fcohen

Screen shot of functional test showing failure in TestGen4Web

Changed 2 months ago by fcohen

  • priority changed from major to blocker

Changed 2 months ago by fcohen

  • type changed from defect to enhancement

Changed 2 months ago by fcohen

  • description modified (diff)

Changed 2 months ago by fcohen

  • description modified (diff)

Changed 2 months ago by fcohen

  • description modified (diff)

Changed 2 months ago by fcohen

  • description modified (diff)

Changed 2 months ago by fcohen

  • description modified (diff)

Changed 2 months ago by fcohen

  • description modified (diff)

Changed 2 months ago by fcohen

New debug commands are in place. Closing this ticket. -Frank

Changed 2 months ago by fcohen

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.