I use Richfaces Selenium library to automate my tests. I have following problem:
i.e. we have <img id='dynID' title="some title" alt="some text"/>
I can click on the element by XPathLocator:
selenium.click(xp("//img[@alt='some text']"));
but I need to get ID of the element too, becase further work with my page depends on this ID. ID is dynamicly generated, so I need to get it using other properties.
How can I get it?
In the library I saw only getSelectedId but it's for SelectLocator.
I've solved it:
XPathLocator xpathLoc = xp("//img[@alt='some text']");
AttributeLocator<XpathLocator> attLocator = xpathLoc.getAttribute(Attribute.ID);
String str = selenium.getAttribute(attLocator);