DMC DMC - 14 days ago 9
Python Question

ID name with SPAN element in Robotfamework

I'm kinda new to robotframework and trying to setup a simple test scenario where i want to validate a numerical value somewhere in a page (should be between 0-40).

In the following screenshot you can see the value (46) which i need to locate.
The problem i face is that the classname

inbasketTabInLine inbasketTabCount
is also used for another value on the second tab. So i assume i could make it specific by also refering to the main ID which is
dijit_layout_TabContainer_0_tablist_ecm_widget_listView_ContentList_0
.
As this value is specific for this tab (Werkvoorraad Supportteam) it should be OK.

My firefox xpath finder gives me the following xpath:

.//*[@id='dijit_layout_TabContainer_0_tablist_ecm_widget_listView_ContentList_0']/span[2]


However, i couldnt translate this into a pathname that robotframework (with pyhton) understands. I'm using the Selenium2Library also.

The following locator works for the Tab title (e.g Werkvoorrad Supportteam):

id=dijit_layout_TabContainer_0_tablist_ecm_widget_listView_ContentList_0


Q: How can i also specify the span[2] element in above?

html code

Answer

So I think you've basically solved this yourself, I'm not sure I see a problem beyond maybe syntax. What exactly is the problem when you say you can't translate it into something robotframework understands. To get this to work I would use the following locator:

xpath=//*[@id="dijit_layout_TabContainer_0_tablist_ecm_widget_listView_ContentList_0"]/span[2]

Does the above work? If not, what is the error reported? It's worth pointing out that using xpaths is far from ideal, they can be brittle and are generally the slowest selector. It would be worthwhile working with your dev team to improve the selectors or doing so yourself if you have dev access and are comfortable making the changes.