Safari vs IE

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Safari vs IE

GW-5
Newbie question here. (Searched the forum but couldn't find this topic.)

I'm writing a script that I want to work on Firefox 1.5.0.3, IE 6.0, and Safari 2.0.3 (for starters). So far, I've run into this experience:

- FF doesn't care about super-specific xpath identifiers.
- IE *needs* super-specific xpath identifiers.
- Safari *chokes* on super-specific xpath identifiers.

Example:
IE needs this:
//body[@id='furl']/div[@id='reContainer']/div[@id='box']/div[@id='topnav']/div[@id='mo']/a[1]/img[@id='hm']

Safari can't stand it. It wants:
//img[@id='hm']

Is there a happy middle ground? Am I running into some weird "I support this xpath standard but not that one" issue? I'm prepared to keep double-copies of scripts around (*shudder*), but it sure would be preferable to write one-size-fits-all tests instead.

Thanks in advance for help and patience.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1936&messageID=5483#5483

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Safari vs IE

Dan Fabulich
J Davis wrote:

> Is there a happy middle ground? Am I running into some weird "I support
> this xpath standard but not that one" issue? I'm prepared to keep
> double-copies of scripts around (*shudder*), but it sure would be
> preferable to write one-size-fits-all tests instead.

Cross-platform XPath support is hard.  What you're seeing here is that
there are really three separate implementations of XPath: the IE ActiveX
implementation, the FF .evaluate implementation, and a pure-JavaScript
implementation of XPath for Safari.  Unfortunately, they each have their
own bugs, many of which can be quite subtle.

You may prefer referring to your elements by a DOM expression
(document.blah.blah) instead (since that's relatively consistent across
browsers) or changing your AUT to have more "id" elements (which makes the
problem trivial).

Alternately, if you simply *must* use XPath, I'd recommend writing your
tests in a richer programming language like Java, C#, VB, Perl, Python or
Ruby, using Selenium Remote Control. That way you can say "If this is
Safari, use XPath foo; if this is IE, use XPath bar..."

http://www.openqa.org/selenium-rc/

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Safari vs IE

GW-5
>
> Cross-platform XPath support is hard.

(Let's go shopping!)

> What you're
> seeing here is that
> there are really three separate implementations of
> XPath: the IE ActiveX
> implementation, the FF .evaluate implementation, and
> a pure-JavaScript
> implementation of XPath for Safari.  Unfortunately,
> they each have their
> own bugs, many of which can be quite subtle.
>
> You may prefer referring to your elements by a DOM
> expression
> (document.blah.blah) instead (since that's relatively
> consistent across
> browsers)

That makes sense.

> or changing your AUT to have more "id"
> elements (which makes the
> problem trivial).

Would that I could. I'm strictly QA...adding "id"s is the developers' job in our org. The original developer was allergic to them, evidently.

>
> Alternately, if you simply *must* use XPath, I'd
> recommend writing your
> tests in a richer programming language like Java, C#,
> VB, Perl, Python or
> Ruby, using Selenium Remote Control. That way you can
> say "If this is
> Safari, use XPath foo; if this is IE, use XPath
> bar..."

Writing the tests in a scripting language just seems like good sense to me. I need to figure out the logistics and just do it.

Thanks!
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1936&messageID=5488#5488

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Safari vs IE

GW-5
In reply to this post by Dan Fabulich
Could you give me a link to a site that explains how to write a DOM string? I've been poking around DOM tutorials, and it seems like there are tools to show a DOM graphically, but no one seems to talk about the syntax of a DOM element identifier. Didn't see anything in the forum archive, either.

Thanks much.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1936&messageID=5515#5515

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Safari vs IE

Dan Fabulich
J Davis wrote:

> Could you give me a link to a site that explains how to write a DOM
> string? I've been poking around DOM tutorials, and it seems like there
> are tools to show a DOM graphically, but no one seems to talk about the
> syntax of a DOM element identifier. Didn't see anything in the forum
> archive, either.

I suspect you may be googling the wrong way here.  We tend to call them
"DOM expressions", but they're really just JavaScript expressions that use
properties and elements of the window.document object to track down the
object in question.  In other words, you're not really looking for a DOM
tutorial, you're looking for a JavaScript tutorial.

So, for example, for IE, you might start here:

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/html/reference/elements.asp

Under "Objects" you'll find the "document" object, and under "document"
you'll find a variety of "collections".  For example, you might use a
collection of links as document.links.

If you want the first link on the page, you can use
document.links[0]; if you want the fourth link on the page, you can use
document.links[3].

If your elements are marked with a "name" attribute, you may want to use
document.getElementsByName("foo") to track them down.  Need all the
tables?  Use document.getElementsByTagName("table").  Need the fourth one?
document.getElementsByTagName("table")[3].

Tables, in turn, have their own collections that you may want to access.
(Click on "table" on the list on your left.)  For example, if you have a
given table in mind, you can refer to its fourth row like this:
document.getElementsByTagName("table")[3].rows[3].  Need a particular cell
within that?  Use rows[3].cells[3].

That'll get you started.  The comparable version of that documentation for
Firefox is here:

http://developer.mozilla.org/en/docs/Gecko_DOM_Reference

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Safari vs IE

GW-5
Thank you so much! With that info, I'll be a DOM expression expert by this afternoon. I really appreciate the help.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1936&messageID=5517#5517

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]