XPath Support in Frame

15 views
Skip to first unread message

Kunal Kumar

unread,
Jan 8, 2010, 5:15:39 AM1/8/10
to watir-...@googlegroups.com
Hi,

I know that currently watir does not support xpath in frames. So for example, statement like

$ie.frame(:index, 3).span( :xpath, "//div[@id='test']/../span" ).click

would fail with error.

I would like to know if there is any development going on to support XPath in Frame or it just can't be done ?

I am not sure why this functionality does not exist in watir ( which would really help for all those folks whoever is using/are planning to use Watir ).

Could someone please explain?

Kunal
Blog: http://www.kspace.in/blog

Željko Filipin

unread,
Jan 8, 2010, 5:29:08 AM1/8/10
to watir-...@googlegroups.com
On Fri, Jan 8, 2010 at 11:15 AM, Kunal Kumar <kunal.kr@gmail.com> wrote:
> $ie.frame(:index, 3).span( :xpath, "//div[@id='test']/../span" ).click
> would fail with error.

That should work. What error do you get?

Take a look:

http://wiki.openqa.org/display/WTR/XPath

"...you can access frames using the attributes that Watir provides but you can't use xpath attribute for accessing frames..."

Željko
--
watir.com - community manager
watirpodcast.com - host



Angrez Singh

unread,
Jan 8, 2010, 5:45:18 AM1/8/10
to watir-...@googlegroups.com
Correct as Željko said it should work?

--
You received this message because you are subscribed to the Google Groups "Watir General" group.
To post to this group, send email to watir-...@googlegroups.com
Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to watir-genera...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/watir-general

Kunal

unread,
Jan 9, 2010, 4:48:16 AM1/9/10
to Watir General
No. They don't. See the error which I get, If I try to do something
like that.

irb(main):025:0> browser.frame( :id, "test-339" ).span( :xpath, "//span
[@text='Root Node']" ).focus

NoMethodError: undefined method `element_by_xpath' for #<Watir::Frame:
0x32f24f4>

from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/
non_control_elements.rb:20:in `locate'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/
element.rb:49:in `assert_exists'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/
element.rb:284:in `enabled?'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/
element.rb:56:in `assert_enabled'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/
element.rb:266:in `focus'
from (irb):25

On Jan 8, 3:45 pm, Angrez Singh <ang...@gmail.com> wrote:
> Correct as Željko said it should work?
>
> On Fri, Jan 8, 2010 at 3:59 PM, Željko Filipin <
>

> zeljko.fili...@wa-research.ch> wrote:


> > On Fri, Jan 8, 2010 at 11:15 AM, Kunal Kumar <kunal...@gmail.com> wrote:
> > > $ie.frame(:index, 3).span( :xpath, "//div[@id='test']/../span" ).click
> > > would fail with error.
>
> > That should work. What error do you get?
>
> > Take a look:
>
> >http://wiki.openqa.org/display/WTR/XPath
>
> > "...you can access frames using the attributes that Watir provides but you

> > can't use *xpath* attribute for accessing frames..."

Angrez Singh

unread,
Jan 9, 2010, 8:48:12 AM1/9/10
to watir-...@googlegroups.com
I'll look into this .. above should work .. meanwhile can you send me the HTML you are using?
 
- Angrez

Kunal

unread,
Jan 9, 2010, 10:41:10 AM1/9/10
to Watir General
Well, the HTML doc is quite big! You would not want to dig into
that ;)

Anyways I tried to remove most of the redundant things and the
skeleton HTML does look something like as below

<html>
<head>
</head>
<body>
<div> Some content here </div>
<iframe src="http://dummy-url">
<html>
<body>
<div id="test-1" > Test test
<div id="test-2" > </div>
<span id="test-span-1"> lkdsjlakjds </span>
<span id="Root-Node" > </span>
</div>
</body>
</html>
</iframe>
</body>
</html>

If this helps, great. If you need more information, please let me
know.

-Kunal

On Jan 9, 6:48 pm, Angrez Singh <ang...@gmail.com> wrote:
> I'll look into this .. above should work .. meanwhile can you send me the
> HTML you are using?
>
> - Angrez
>

Angrez Singh

unread,
Jan 11, 2010, 1:36:06 AM1/11/10
to watir-...@googlegroups.com
Thanks a lot for the HTML source .. it is sufficient. Will look into the issue and resolve it.

- Angrez

Wesley Chen

unread,
Jan 11, 2010, 2:33:20 AM1/11/10
to watir-...@googlegroups.com
I met with this kind of problem, too.
In fact, when I user IE developer toolbar to access the web page with the source code above, the IFRAME won't expand.
The IFrame is with src attributes, it points to the other place, which crosses the domain, so we have no access.

Thanks.
Wesley Chen.
For life, the easier, the better.

Kunal

unread,
Jan 14, 2010, 9:04:23 AM1/14/10
to Watir General
Hi Angrez,

Do you think this issue can be solved ?

-Kunal

On Jan 11, 12:33 pm, Wesley Chen <cjq....@gmail.com> wrote:
> I met with this kind of problem, too.
> In fact, when I user IE developer toolbar to access the web page with the
> source code above, the IFRAME won't expand.
> The IFrame is with src attributes, it points to the other place, which
> crosses the domain, so we have no access.
>
> Thanks.
> Wesley Chen.
> For life, the easier, the better.
>
> On Mon, Jan 11, 2010 at 2:36 PM, Angrez Singh <ang...@gmail.com> wrote:
> > Thanks a lot for the HTML source .. it is sufficient. Will look into the
> > issue and resolve it.
>
> > - Angrez
>

> > 2010/1/9 Kunal <kunal...@gmail.com>

Wesley Chen

unread,
Jan 14, 2010, 8:20:21 PM1/14/10
to watir-...@googlegroups.com
I think the xpath is not supported when in a frame.


Thanks.
Wesley Chen.
For life, the easier, the better.


Kunal

unread,
Jan 14, 2010, 11:52:44 PM1/14/10
to Watir General
Yes. That's what it looks right now.

Question is - Can this be supported? May be Angrez can throw some
light.

-Kunal

On Jan 15, 6:20 am, Wesley Chen <cjq....@gmail.com> wrote:
> I think the xpath is not supported when in a frame.
>
> Thanks.
> Wesley Chen.
> For life, the easier, the better.
>

Angrez Singh

unread,
Jan 15, 2010, 1:32:00 AM1/15/10
to watir-...@googlegroups.com
Hi Kunal,

I didn't get enough time to look into the issue. I'll surely get something done this week end.

- Angrez
Reply all
Reply to author
Forward
0 new messages