Value which needs scrolling not getting selected
Posted: Fri Jan 25, 2013 1:08 pm
Hi Support,
In Desktop application, I want to select value from drop-down which needs scrolling. But its not working with this code snippet-
Can you please elaborate what needs to correct here? Please find RX snapshot of Drop-down and screenshot of error from RX log.
Thanks in advance,
Varun.
In Desktop application, I want to select value from drop-down which needs scrolling. But its not working with this code snippet-
Code: Select all
methodcall()
{
MethodName("ElementName", Variable);
}
public static int MethodName(string ComboName, string ComboItem)
{
try
{
Thread.Sleep(500);
}
catch (RanorexException e)
{
Report.Error("Unable to find ComboBox: " + ComboName);
Console.WriteLine(e.ToString());
Report.Screenshot();
return -1;
}
try
{
Report.Info("Selecting item: " + ComboItem + " in ComboBox: " + ComboName);
Thread.Sleep(1000);
// Thread.Sleep(1000);
ComboBox item = "/container[@controlname='nextActiveControl']/listitem[@text='" + ComboItem + "']";
// ListItem item = "/container/container[@controlname='nextActiveControl']/listitem[@text='" + ComboItem + "']";
if (item.Visible == false)
{
Keyboard.Press("{HOME}");
Thread.Sleep(500);
while (item.Visible == false)
{
Keyboard.Press("{PageDown}");
Thread.Sleep(500);
}
}
item.Click(Location.Center, 1000);
Report.Debug(" Selected item: " + ComboItem + " in ComboBox: " + ComboName);
}
catch (RanorexException e)
{
Report.Error(e.ToString());
Report.Screenshot();
return -1;
}
return 0;
}
Thanks in advance,
Varun.