Find a special Row

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
thecrazykaktus
Posts: 13
Joined: Wed Feb 19, 2014 12:24 pm

Find a special Row

Post by thecrazykaktus » Thu Feb 20, 2014 1:06 pm

Hi,
Unfortunately I have another problem.

I have a table with multiple rows and columns.
There, I'm trying to find a special content and I want to click this. (Example Absender = Ralf Goebe, Betreff = ticktack)

Picture of the table with content

Image
Image

How can I realize it?

My idea was

Code: Select all

/dom[@domain='...']//div[#'ifrdiv_comcat']/iframe[@id='ifr_comcat']//tbody[#'form_vertical_mainView:mainViewRenderer:emails_data']/tr/td[@innertext='Ralf Goebel']/../td[@innertext='test']
However, it is always chosen only the first line
You do not have the required permissions to view the files attached to this post.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Find a special Row

Post by krstcs » Thu Feb 20, 2014 2:31 pm

You could try using the "parent::" and "following-sibling::" relative path expressions.

See this page in the documentation: http://www.ranorex.com/support/user-gui ... html#c5804

With the structure you are showing in the screen shot it would be several levels of pathing to find the right one.

Also, it is better to include a Ranorex Snapshot if possible so we can all see the structure more easily. http://www.ranorex.com/support/user-gui ... files.html
Shortcuts usually aren't...

QaTester
Posts: 11
Joined: Fri Nov 08, 2013 8:03 pm

Re: Find a special Row

Post by QaTester » Wed Feb 26, 2014 11:35 pm

I would make use of the TryFindSingle method, described in the Ranorex documentation found here

In your case, I would enter the Table object into a repository, make it a variable in user code and then call the TryFindSingle method on it. I would then make the attribute used inside of the xpath a variable.

Like so:
var repo = myRepo.Instance;
var table = repo.myTable; 

string myAttribute = "test"; 
bool controlFound; 
SpanTag control = null;
controlFound =  table.TryFindSingle<SpanTag>(String.Format("//span[@innertext='" + myAttribute + "']"), out control);

if(control != null)
    control.Click();

Obviously you could substitute certain parts of the code to meet your needs, but looking at your screenshots and your post I assumed you wanted a Span tag with a certain innertext that you specify.

Additionally, if you wanted to make sure that the cell you find is found within a specific column, I would use an 'and' operator in the x-path and pass the childIndex that corresponds to the column.

Say for instance all values found in the 'Absender' column were the third child of the table row:

Code: Select all

"//span[@innertext='" + myAttribute + "' and @childIndex='3']"

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Find a special Row

Post by mzperix » Wed Mar 12, 2014 2:35 pm

THe Xpath you wrote applies to the first row, since in the Betreff column the "test" string is in the first row.

If you want to apply it to the ticktack row, then the proper xpath would be:

Code: Select all

/dom[@domain='...']//div[#'ifrdiv_comcat']/iframe[@id='ifr_comcat']//tbody[#'form_vertical_mainView:mainViewRenderer:emails_data']/tr/td[@innertext='Ralf Goebel']/../td[@innertext='ticktack']
You can put variables instead of the two search strings (Ralf Goebel and ticktack). If the xpath finds more than one result, then it will use the first it finds.