18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

The way that sahi fetch HTML attributes

ytchytch Members
edited September 2011 in Sahi - Open Source
Hi,

I come across a design problem in Sahi by accident, It is about the way to get HTML attribute.
In Sahi, many locator need html attribute to locate elements,
and I can customize it in concat.js:Sahi.prototype.prepareADs

But I find that sahi use attributes array like : el["href"], rather then getAttribute() method
to read attribute. This two have a difference in firefox:

If I add a custom-named attribute that not in HTML standard, like the flag attribute:
<a href="example.com" flag="1">link</a>

el["flag"] will return null, but el.getAttribute("flag") will get "1"

I've modified:
Sahi.prototype._getAttribute
Sahi.prototype.areEqual2
Sahi.prototype.getAttribute
to use getAttribute, and it seems no problem.
Is there any problem, so use array rather then getAttribute?

Comments

  • narayannarayan Administrators
    Hi ytch,
    Your use of getAttribute is correct. We had made the same change a few days back, to accommodate custom attributes.
    Regards,
    Narayan
  • Hi narayan,

    Thanks, I'm looking forward for next release :)
This discussion has been closed.