Page 1 of 1

The element does not support the required capability 'table'

Posted: Wed Apr 01, 2015 9:57 pm
by zoework
I get this error in my custom code. I'm trying to search through a table in my application to determine in which row the data is that I want to change.
The table has several columns and multiple rows for the same product. I need to find the row where the product has a specific value. For instance, which product is sold out.
Here is the code I'm using:
public void SelectOrder()
{
//Table varTable = "/dom[@domain='qa.xxx.sss.com']//div[#'content']/div[2]/div[2]/div[1]/div/div/div/div/div/table/tbody[2]/";
//Table varTable = "/dom[@caption=Shopping]//div[#'content']/div[2]/div[2]/div[1]/div/div/div/div/div/table/tbody[2]/";
Table varTable = "/dom[@caption=Shopping]//div[#'content']/div[2]/div[2]/div[1]/div/div/";
var varRows = varTable.Rows;
foreach (var row in varRows)
{
var varProduct = "tr["+row+"]/td[@innertext]";
if(varProduct == "Rice")
{
var varStatus = "tr["+row+"]/td[@innertext]";
if (varStatus == "Sold Out")
{
tableRowNum = row.ToString();
}
}
}
}//end SelectOrder function


I tried all three versions of the table item definitions above and they all throw the same error. How should I specify the table?

Re: The element does not support the required capability 'table'

Posted: Thu Apr 02, 2015 7:37 am
by CookieMonster
Hi Zöe,

With Ranorex XPath examples you are using in the Method SelectOrder, you will never be able to instantiate a Table object. You have to use the TableTag Object to instantiate a web table and also your XPath with which you are trying to instantiate the table is wrong.

In this example you are using the wrong table object and body[2]/ is too much.

Code: Select all

//Table varTable = "/dom[@domain='qa.xxx.sss.com']//div[#'content']/div[2]/div[2]/div[1]/div/div/div/div/div/table/tbody[2]/";
It should look like the line below.

Code: Select all

TableTag varTable = "/dom[@domain='qa.xxx.sss.com']//div[#'content']/div[2]/div[2]/div[1]/div/div/div/div/div/table";
And please ask your web developer if he/she can add an unique id to the table tag. Then your XPaht can look like:
/dom[@domain='qa.xxx.sss.com']//div[#'content']//table[#'ordertable']";

And also try to avoid using indexes in the XPath, if the developer is changing the table from div[2] to div[5] the table will never be found.

Cheers
Dan