[ptt-users] Xpath issue
Olivier Dony
olivier.dony at denali.be
Fri Sep 28 15:20:13 PDT 2007
On Sep 28, 2007, at 5:39 PM, Lars Huttar wrote:
> Is there a way to have TM *not* run the test through the conversion
> layer?
> Maybe by using a different type of unit test (i.e. not <tg4w>)?
> Or not until a selenium test interpreter becomes available?
I don't think there's an easy way to execute a tg4w scenario without
the converter, at least not out-of-the-box.
TestMaker supports test scripts written in many languages, but if you
want to execute a TestGen4Web scenario directly the only way is to
use this builtin converter. Because in the end you need to turn this
list of actions into a real browser session, simulated using htmlunit.
Of course you could also write your own "test driver module" in any
of the supported languages, or patch the current converter.
>> This is done by TestGenForWeb.normalizeXPath(). You can have a
>> look at it if you're interested:
>> http://cvs.pushtotest.com/cgi-bin/cvsweb.cgi/tm5/TestMaker/src/
>> com/pushtotest/testmaker/XSTest/client/TestGenForWeb.java?
>> annotate=HEAD
>>
> Looking at this code, it's surprisingly naive, for a product that
> claims to enable you to automatically generate test cases.
> It's tempting to try and write a patch to improve the parsing, but
> I wonder if it's worth it... writing a parser is notoriously time-
> consuming, probably more so for a pseudo-language that seems to be
> undocumented.
> Maybe a good approach would be to try to "normalize" the XPath
> after it's parsed by the Jaxen XPath parser (which is already used
> by this code, via Gargoyle's HtmlUnitXPath).
> E.g. using BaseXPath.getRootExpr().
> If the XPath parser can handle TG4W-XPath.
>
> But maybe the time of TM users and developers would be better spent
> getting TM to work with a tool that produces real XPath, like
> Selenium.
To me the tg4w converter looks like a quickly written tool to enable
non-programmers to generate test scripts via a GUI, and still be able
to run them in TM easily. It definitely needs improvement, but were
it much more robust/flexible, I think the expression power of an
"interpreted" tg4w scenario is still quite limited.
Within my company we are working on an alternative way to generate
test scripts, starting by recording the scenarios with Selenium
(using real XPath), then converting the scenario into a jython
script, which can be executed by TestMaker as a load-test.
Oonce you have the automatically generated jython script, you can
modify the scenario as you wish, introduce more complexity, randomize
it, etc.
(Note that htmlunit is still the workhorse behind the jython script,
as it does the job really well.)
This is a work in progress, but we have been in touch with Frank
Cohen about it, and hopefully this (or something similar) should be
integrated into TestMaker at some point.
--
Olivier Dony
Denali s.a., "Bridging the gap between Business and IT"
Rue de Clairvaux 8, B-1348 Louvain-la-Neuve, Belgium
Office: +32 10 43 99 51 Fax: +32 10 43 99 52
www.denali.be
Legal Notice: this message may contain confidential and/or privileged
information. If you are not the addressee or authorized to receive
this for the addressee, you must not use, copy, disclose or take any
action based on this message or any information herein. If you have
received this message by mistake, please advise the sender
immediately by return e-mail and delete this message from your
system. Thank you for your cooperation.
More information about the Users
mailing list