18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
How to use getAttribute in JUnit
Hi
I am testing a Ext Js site, and the id is dynamic. The only locator is the "for" attribute. And I need to use Sahi in Java mode to build the test framework with TestNG.
I can make it with javascriput like this:
_setValue(_textbox(_label($searchType).getAttribute('For')),$typeName);
but how to do it with Java mode, which API can be used to do this? Thanks
I am testing a Ext Js site, and the id is dynamic. The only locator is the "for" attribute. And I need to use Sahi in Java mode to build the test framework with TestNG.
I can make it with javascriput like this:
_setValue(_textbox(_label($searchType).getAttribute('For')),$typeName);
but how to do it with Java mode, which API can be used to do this? Thanks
This discussion has been closed.
Comments
browser.label(searchType).fetch("For")
I try to look into the attributes of Browser element itself. print out browser.label(searchCriteria).fetch(). but it get [object HTMLLabelElement],
However, fetch("innerHTML") can get the value.
You can do:
This will work on Firefox but not on IE.
The right way to get the "for" attribute for a label is to get the "htmlFor" property. You can do
This will work for all browsers.
Regards,
Narayan