Trouble selecting a checkbox with usercode

Class library usage, coding and language questions.
AdamMackintosh
Posts: 19
Joined: Mon Jun 08, 2015 6:21 am

Re: Trouble selecting a checkbox with usercode

Post by AdamMackintosh » Thu Jun 11, 2015 6:59 pm

OMG I fixed it!

The problem was the path to that delete button was too specific somehow, so I made it a bit looser and it instantly worked :)

Here is my working code:
public void Validate_TrackTable()
        {
 			IList<Ranorex.ATag> foundTags = repo.VoloMP.TrackTable.Find<Ranorex.ATag>(@".//input[@tagvalue~'nhd6mid.BG6uvr7i']/../..//a[@id='deleteMe']");  
 			Report.Log(ReportLevel.Info, "Test", "Table grabbed.", repo.VoloMP.TrackTableInfo);
    		foreach (ATag curATag in foundTags)   
    		{  
		        curATag.PerformClick();  
		        Report.Log(ReportLevel.Info, "Test", "We should see 3 of these: "+curATag.InnerText, repo.VoloMP.TrackTableInfo);
	    	}  
        }
Here is my log output, which is exactly how it should have looked:
00:02.358 Info Test Table grabbed.
00:02.387 Info Test We should see 3 of these: delete
00:02.416 Info Test We should see 3 of these: delete
00:02.443 Info Test We should see 3 of these: delete
It also clicks on the 3 delete buttons it was supposed to, so extreme thanks to odklizec. I couldn't have done it without you.

-Adam

AdamMackintosh
Posts: 19
Joined: Mon Jun 08, 2015 6:21 am

Re: Trouble selecting a checkbox with usercode

Post by AdamMackintosh » Thu Jun 11, 2015 7:01 pm

odklizec wrote:Hi,

I believe you forgot to escape "." in changed xpath. This code shoud work...
IList<Ranorex.ATag> foundTags = repo.VoloMP.TrackTable.Find<Ranorex.ATag>(@".//input[@tagvalue~'nhd6mid\.BG6uvr7i']/../..//a[#deleteMe]");

WHen i put that path fragment into SPy, it was alwasy returning only the first match, so I did some diagnosis and found a way to get all 9 delete buttons, then i cleaned it up as you can see in my previous post to match the 3 that I wanted.

There is actually two delete buttons in each row, so I had to use /a[@id='deleteMe'] to zoom in on the correct one. That was the specific change that fixed everything.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Trouble selecting a checkbox with usercode

Post by odklizec » Thu Jun 11, 2015 7:06 pm

Hm, that's weird. I believe I tried it with escaped string and it worked for me, while it didn't work at all with unescaped string? Anyway, good to hear you solved it. I'm glad I could help :)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration