|
From: rbkcbe <rb...@gm...> - 2008-03-25 13:59:44
|
Dear All, Using the class HtmlUnitXPath, we can get HtmlElements using xPath. But how to get the xPath of selected HtmlElement? Thanks in advance! Bala -- View this message in context: http://www.nabble.com/How-to-get-xPath-from-HU-DOM-tree--tp16274911p16274911.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |
|
From: D&J G. <djg...@gm...> - 2008-03-25 16:55:20
|
Hi Bala, I don't think this feature exists, as of yet (someone correct me if I'm wrong). You can always build your own by recursing up the ancestor nodes for the element in question. You can also file a feature request, if you want. Regards, Daniel On Tue, Mar 25, 2008 at 9:59 AM, rbkcbe <rb...@gm...> wrote: > > Dear All, > > Using the class HtmlUnitXPath, we can get HtmlElements using xPath. But > how > to get the xPath of selected HtmlElement? > > Thanks in advance! > Bala > -- > View this message in context: > http://www.nabble.com/How-to-get-xPath-from-HU-DOM-tree--tp16274911p16274911.html > Sent from the HtmlUnit - General mailing list archive at Nabble.com<http://nabble.com/> > . > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > -- Daniel Gredler http://daniel.gredler.net/ |
|
From: rbkcbe <rb...@gm...> - 2008-03-25 22:38:22
|
Hi Daniel, Thanks for the information. I think this feature will be very handy when integrating HU with Unit Test tools. I'll file a Feature request. Thanks, Bala gredler wrote: > > Hi Bala, > > I don't think this feature exists, as of yet (someone correct me if I'm > wrong). You can always build your own by recursing up the ancestor nodes > for > the element in question. You can also file a feature request, if you want. > > Regards, > > Daniel > > On Tue, Mar 25, 2008 at 9:59 AM, rbkcbe <rb...@gm...> wrote: > >> >> Dear All, >> >> Using the class HtmlUnitXPath, we can get HtmlElements using xPath. But >> how >> to get the xPath of selected HtmlElement? >> >> Thanks in advance! >> Bala >> -- >> View this message in context: >> http://www.nabble.com/How-to-get-xPath-from-HU-DOM-tree--tp16274911p16274911.html >> Sent from the HtmlUnit - General mailing list archive at >> Nabble.com<http://nabble.com/> >> . >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2008. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Htmlunit-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> > > > > -- > Daniel Gredler > http://daniel.gredler.net/ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > -- View this message in context: http://www.nabble.com/How-to-get-xPath-from-HU-DOM-tree--tp16274911p16290443.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |
|
From: Marc G. <mgu...@ya...> - 2008-03-26 07:43:22
|
I seriously doubt that it makes sense: there is not a unique xpath expression that allows to select a node and which one is the best depends from the usage you have of it, from what is fixed in the page and what is likely to change. Cheers, Marc. -- Blog: http://mguillem.wordpress.com rbkcbe wrote: > Hi Daniel, > > Thanks for the information. > > I think this feature will be very handy when integrating HU with Unit Test > tools. I'll file a Feature request. > > > Thanks, > Bala > > > gredler wrote: >> Hi Bala, >> >> I don't think this feature exists, as of yet (someone correct me if I'm >> wrong). You can always build your own by recursing up the ancestor nodes >> for >> the element in question. You can also file a feature request, if you want. >> >> Regards, >> >> Daniel >> >> On Tue, Mar 25, 2008 at 9:59 AM, rbkcbe <rb...@gm...> wrote: >> >>> Dear All, >>> >>> Using the class HtmlUnitXPath, we can get HtmlElements using xPath. But >>> how >>> to get the xPath of selected HtmlElement? >>> >>> Thanks in advance! >>> Bala >>> -- >>> View this message in context: >>> http://www.nabble.com/How-to-get-xPath-from-HU-DOM-tree--tp16274911p16274911.html >>> Sent from the HtmlUnit - General mailing list archive at >>> Nabble.com<http://nabble.com/> >>> . >>> >>> >>> ------------------------------------------------------------------------- >>> This SF.net email is sponsored by: Microsoft >>> Defy all challenges. Microsoft(R) Visual Studio 2008. >>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> _______________________________________________ >>> Htmlunit-user mailing list >>> Htm...@li... >>> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >>> >> >> >> -- >> Daniel Gredler >> http://daniel.gredler.net/ >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2008. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Htmlunit-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> >> > |
|
From: Ahmed A. <asa...@ya...> - 2008-03-27 07:53:44
|
Dear Marc, It is true that there is no unique xpath expression, but having something like "/html/body/table[3]/tr[5]/div/a" can by used. @all What do you think? should we have this feature or not? Ahmed -- View this message in context: http://www.nabble.com/How-to-get-xPath-from-HU-DOM-tree--tp16274911p16323326.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |
|
From: George D. <li...@iD...> - 2008-03-27 13:33:15
|
Marc Guillemot wrote:
> Ahmed Ashour wrote:
>> Dear Marc,
>>
>> It is true that there is no unique xpath expression, but having something
>> like "/html/body/table[3]/tr[5]/div/a" can by used.
>
> this is an awful xpath xpath expression because it will probably stop to
> work after a minimal change in the page, even when it is not related to
> the targeted node. This kind of xpath expressions are typical from
> people starting test automation of web applications.
FWIW, I've found such canonical paths a helpful starting point when
deciding on an effective xpath expression. Alex Chaffee's Xpath
Explorer is the tool I've generally use (as dated as it is). I can
envision that, were it available, a statement like
assertEquals("", element.getCanonicalXPath());
might be a convenient shortcut to retrieving this information in the
tool I'm already using.
I'm not arguing for or against the facility; just pointing out how I
might possibly use it were it available.
- George
P.S. Thanks for all the fine work on HtmlUnit!
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------
|
|
From: Marc G. <mgu...@ya...> - 2008-03-27 13:46:42
|
George Dinwiddie wrote:
> Marc Guillemot wrote:
>> Ahmed Ashour wrote:
>>> Dear Marc,
>>>
>>> It is true that there is no unique xpath expression, but having something
>>> like "/html/body/table[3]/tr[5]/div/a" can by used.
>> this is an awful xpath xpath expression because it will probably stop to
>> work after a minimal change in the page, even when it is not related to
>> the targeted node. This kind of xpath expressions are typical from
>> people starting test automation of web applications.
>
> FWIW, I've found such canonical paths a helpful starting point when
> deciding on an effective xpath expression. Alex Chaffee's Xpath
> Explorer is the tool I've generally use (as dated as it is). I can
> envision that, were it available, a statement like
> assertEquals("", element.getCanonicalXPath());
> might be a convenient shortcut to retrieving this information in the
> tool I'm already using.
>
> I'm not arguing for or against the facility; just pointing out how I
> might possibly use it were it available.
>
> - George
>
> P.S. Thanks for all the fine work on HtmlUnit!
>
in fact I have the idea since a long time of an "XPath picker" tool for
my WebTest Recorder firefox extension that would be able to generate
"more intelligent" xpath expressions but I've never found time to
realize it.
Cheers,
Marc.
--
Blog: http://mguillem.wordpress.com
|
|
From: Ahmed A. <asa...@ya...> - 2008-03-25 18:02:34
|
Dear Bala,
I am trying to understand, so please correct me.
>>Using the class HtmlUnitXPath, we can get HtmlElements using xPath.
You shouldn't directly use HtmlUnitXPath, you should use element.getByXPath() instead.
>> But how to get the xPath of selected HtmlElement?
I guess this question should be: "how to get selected HtmlElement", right?
Selected element is current element in focus? If yes, then HtmlPage.getElementInFocus().
But if you mean: how to get xpath of already returned elements from the previous xpath expression, then this is a difficult question, for which a feature request has to be created.
Hope that helps,
Yours,
Ahmed
On Tue, Mar 25, 2008 at 9:59 AM, rbkcbe <rb...@gm...> wrote:
Dear All,
Using the class HtmlUnitXPath, we can get HtmlElements using xPath. But how
to get the xPath of selected HtmlElement?
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
|
From: rbkcbe <rb...@gm...> - 2008-03-27 18:57:01
|
Dear Ahmed, I'm so glad to read the mail thread. Our requirement is exactly as you mentioned in earlier post "/html/body/table[3]/tr[5]/div/a" We've custom framework to select an element by specifying the AnchorText. In order to integrate our test written using (FitNesse + HtmlUnit) with other WebTest tools (Selenium) for complex AJAX calls where a real browser is must, we need the xPath information of the selected element. The above simple xPath is sufficient for the integration purpose. We don't need legible xPath so that other developers can understand. I'm fine with Marc suggestion - element.getCanonicalXPath() Hope I explained the requirement well. Thanks a lot Bala Ahmed Ashour wrote: > > Dear Bala, > > I am trying to understand, so please correct me. > >>>Using the class HtmlUnitXPath, we can get HtmlElements using xPath. > > You shouldn't directly use HtmlUnitXPath, you should use > element.getByXPath() instead. > >>> But how to get the xPath of selected HtmlElement? > > I guess this question should be: "how to get selected HtmlElement", right? > > Selected element is current element in focus? If yes, then > HtmlPage.getElementInFocus(). > > > But if you mean: how to get xpath of already returned elements from the > previous xpath expression, then this is a difficult question, for which a > feature request has to be created. > > Hope that helps, > > Yours, > Ahmed > > On Tue, Mar 25, 2008 at 9:59 AM, rbkcbe <rb...@gm...> wrote: > > > Dear All, > > Using the class HtmlUnitXPath, we can get HtmlElements using xPath. But > how > to get the xPath of selected HtmlElement? > > > > ____________________________________________________________________________________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > -- View this message in context: http://www.nabble.com/How-to-get-xPath-from-HU-DOM-tree--tp16274911p16331159.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |
|
From: Marc G. <mgu...@ya...> - 2008-03-27 08:34:26
|
Ahmed Ashour wrote: > Dear Marc, > > It is true that there is no unique xpath expression, but having something > like "/html/body/table[3]/tr[5]/div/a" can by used. this is an awful xpath xpath expression because it will probably stop to work after a minimal change in the page, even when it is not related to the targeted node. This kind of xpath expressions are typical from people starting test automation of web applications. We can add such a method as getCanonicalXPath or something like that *but* only if with a comment like my previous one. Cheers, Marc. -- Blog: http://mguillem.wordpress.com |
|
From: D&J G. <djg...@gm...> - 2008-03-27 13:51:49
|
I like the idea. As mentioned elsewhere, it can provide a good start to a better expression. We can add a bunch of disaclaimers to the javadoc :-) On Thu, Mar 27, 2008 at 4:37 AM, Marc Guillemot <mgu...@ya...> wrote: > Ahmed Ashour wrote: > > Dear Marc, > > > > It is true that there is no unique xpath expression, but having > something > > like "/html/body/table[3]/tr[5]/div/a" can by used. > > this is an awful xpath xpath expression because it will probably stop to > work after a minimal change in the page, even when it is not related to > the targeted node. This kind of xpath expressions are typical from > people starting test automation of web applications. > > We can add such a method as getCanonicalXPath or something like that > *but* only if with a comment like my previous one. > > Cheers, > Marc. > -- > Blog: http://mguillem.wordpress.com > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > -- Daniel Gredler http://daniel.gredler.net/ |
|
From: Ahmed A. <asa...@ya...> - 2008-03-27 21:05:32
|
Added in SVN, enjoy.
----- Original Message ----
From: Ahmed Ashour <asa...@ya...>
To: htm...@li...
Sent: Thursday, March 27, 2008 10:03:12 PM
Subject: Re: [Htmlunit-user] How to get xPath from HU-DOM tree?
Fair enough, stay tuned :)
----- Original Message ----
From: rbkcbe <rb...@gm...>
To: htm...@li...
Sent: Thursday, March 27, 2008 9:56:57 PM
Subject: Re: [Htmlunit-user] How to get xPath from HU-DOM tree?
Dear Ahmed,
I'm so glad to read the mail thread.
Our requirement is exactly as you mentioned in earlier post
"/html/body/table[3]/tr[5]/div/a"
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs |
|
From: rbkcbe <rb...@gm...> - 2008-04-03 13:32:36
|
Hi Ahmed,
I modified (element.getCanonicalXPath())
"/html/body/table[3]/tr[5]/div/a"
to relative xPath
//table[3]/tr[5]/div/a
it worked very well.
Thank you once again
Bala
Ahmed Ashour wrote:
>
> Added in SVN, enjoy.
>
>
> ----- Original Message ----
> From: Ahmed Ashour <asa...@ya...>
> To: htm...@li...
> Sent: Thursday, March 27, 2008 10:03:12 PM
> Subject: Re: [Htmlunit-user] How to get xPath from HU-DOM tree?
>
>
> Fair enough, stay tuned :)
>
>
> ----- Original Message ----
> From: rbkcbe <rb...@gm...>
> To: htm...@li...
> Sent: Thursday, March 27, 2008 9:56:57 PM
> Subject: Re: [Htmlunit-user] How to get xPath from HU-DOM tree?
>
>
> Dear Ahmed,
>
> I'm so glad to read the mail thread.
>
> Our requirement is exactly as you mentioned in earlier post
>
> "/html/body/table[3]/tr[5]/div/a"
>
>
>
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it
> now.
>
>
>
> ____________________________________________________________________________________
> Never miss a thing. Make Yahoo your home page.
> http://www.yahoo.com/r/hs
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Htmlunit-user mailing list
> Htm...@li...
> https://lists.sourceforge.net/lists/listinfo/htmlunit-user
>
>
--
View this message in context: http://www.nabble.com/How-to-get-xPath-from-HU-DOM-tree--tp16274911p16467483.html
Sent from the HtmlUnit - General mailing list archive at Nabble.com.
|
|
From: Marc G. <mgu...@ya...> - 2008-04-03 13:37:59
|
strange, such XPath expressions should never find anything because: - tr may not directly contained in table but in tbody (or thead or tfooter) - div may not be directly contained in a tr. td missing? Cheers, Marc. -- Blog: http://mguillem.wordpress.com rbkcbe wrote: > Hi Ahmed, > > I modified (element.getCanonicalXPath()) > > "/html/body/table[3]/tr[5]/div/a" > > to relative xPath > > //table[3]/tr[5]/div/a > > it worked very well. > > Thank you once again > Bala > > > Ahmed Ashour wrote: >> Added in SVN, enjoy. >> >> >> ----- Original Message ---- >> From: Ahmed Ashour <asa...@ya...> >> To: htm...@li... >> Sent: Thursday, March 27, 2008 10:03:12 PM >> Subject: Re: [Htmlunit-user] How to get xPath from HU-DOM tree? >> >> >> Fair enough, stay tuned :) >> >> >> ----- Original Message ---- >> From: rbkcbe <rb...@gm...> >> To: htm...@li... >> Sent: Thursday, March 27, 2008 9:56:57 PM >> Subject: Re: [Htmlunit-user] How to get xPath from HU-DOM tree? >> >> >> Dear Ahmed, >> >> I'm so glad to read the mail thread. >> >> Our requirement is exactly as you mentioned in earlier post >> >> "/html/body/table[3]/tr[5]/div/a" >> >> >> >> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it >> now. >> >> >> >> ____________________________________________________________________________________ >> Never miss a thing. Make Yahoo your home page. >> http://www.yahoo.com/r/hs >> ------------------------------------------------------------------------- >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace >> _______________________________________________ >> Htmlunit-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> >> > |