I cant track option tag in my application using Ranorex spy

Ask general questions here.
dineshkumar
Posts: 3
Joined: Wed Apr 07, 2010 8:22 am

I cant track option tag in my application using Ranorex spy

Post by dineshkumar » Tue Apr 13, 2010 6:06 am

Hi,


I can able to map <option> tag(select) in my application and able to access its innertext and also able to select it but I cant click that <option> tag.

My code is:

if (wb != null)
{
Ranorex.TdTag MSo_cell = frmSL.FindSingle<Ranorex.TdTag>("*//td[@id='MSOZoneCell_WebPartWPQ4']");
Ranorex.SelectTag lbsupplier = MSo_cell.FindSingle<Ranorex.SelectTag>("*//select[@id='lblSupplier']");
IList<Ranorex.OptionTag> opts = lbsupplier.FindChildren<Ranorex.OptionTag>();

Random RandomClass = new Random();
int Random_Supplier=RandomClass.Next(1, opts.Count);
opts[Random_Supplier].Selected = true; //here I can able to select that option tag
opts[Random_supplier].PerformClick(); //I cant click that option tag



Is there any other possibilities?
Any help plz..?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: I cant track option tag in my application using Ranorex spy

Post by Support Team » Tue Apr 13, 2010 10:38 am

Hi!

WebElement.PerformClick() only simulate a mouse click on an element without actually moving/clicking the mouse. WebElement.Click() instead move the mouse and is not simualting.
But anyway so in your case you should use following code, so you will get success.
DropDown.Click(Loacation.CenterRight);
Option[2].Click();
You have to open the Drop Down first, because the list exists only when drop down is open. You can test it with only
Option[2].Click();
there you will see that Ranorex is clicking on the right location, but cannot select the item because the item doesn't exist.

IMHO, the best way is set the select option to true, as you done in code.

Regards,
Peter
Ranorex Support Team
.
Image

dineshkumar
Posts: 3
Joined: Wed Apr 07, 2010 8:22 am

Re: I cant track option tag in my application using Ranorex spy

Post by dineshkumar » Tue Apr 13, 2010 12:24 pm

Hi Peter,

Thanks for your reply...

But its not a drop down list and its a list box(having scroll bar) and for ur reference i attached a jpeg image in which there is the listbox " Supplier".

Hence your code clicks on the center right of the list box and its not what i want?

Regards,
Dinesh.
Attachments
untitled.JPG
untitled.JPG (86.48 KiB) Viewed 1195 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: I cant track option tag in my application using Ranorex spy

Post by Support Team » Wed Apr 14, 2010 4:19 pm

Hi Dinesh!

I've tried the same code with a little example aspx.
Ranorex.SelectTag _select = Host.Local.FindSingle<Ranorex.SelectTag>(".//select[@id='ListBox1']");
IList<Ranorex.OptionTag> _optionTagList = _select.FindChildren<Ranorex.OptionTag>();                
Random _rand = new Random();
int i = _rand.Next(1, _optionTagList.Count);                       
_optionTagList.Selected = true;                
_optionTagList.PerformClick();


And i get the result that PerformClick method is working for list box.
I also send you my Projects (Ranorex and ASPX example) as a private message so you can take a look on it.

Regards,
Peter
Ranorex Support Team
.
Image

dineshkumar
Posts: 3
Joined: Wed Apr 07, 2010 8:22 am

Re: I cant track option tag in my application using Ranorex spy

Post by dineshkumar » Thu Apr 15, 2010 7:13 am

Hi Peter,
I already sent you one jpeg image..in that there are two list boxes...one is supplier and another one is Prductline....


# Ranorex.SelectTag _select = Host.Local.FindSingle<Ranorex.SelectTag>(".//select[@id='ListBox1']");
# IList<Ranorex.OptionTag> _optionTagList = _select.FindChildren<Ranorex.OptionTag>();
# Random _rand = new Random();
# int i = _rand.Next(1, _optionTagList.Count);
# _optionTagList.Selected = true;
# _optionTagList.PerformClick();

The above coding works correctly for the listbox "productline" because in the source of that webpage it is on onclick event as I shown below...

onclick="javascript:FilterProductLine(this)


but for the listbox "Supplier" in the source it is on onchange event as

onchange="javascript:FilterSupplier(this)


hence the code you sent didn't work....

for that I tried to call script using ExecuteScript() but I dont know how to call that script using the method...

In addition to that there is no other option for onchange() in Ranorex.....


What can I do now?

Thanks..
Dinesh

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: I cant track option tag in my application using Ranorex spy

Post by Support Team » Fri Apr 16, 2010 11:59 am

As Peter stated in his first posting, try using Click instead of PerformClick. It can be that the web browser does not execute the "OnChange" event if you do not click the option with the mouse.

Regards,
Alex
Ranorex Support Team
.
Image