Select item on List Item using code
Select item on List Item using code
Hello ppl!
I'm using Ranorex last version at this moment and i need to ask you a question.
I have 1 List Item where i need to select and click on a certain date i.e "2008/11" if i do that using the recorder and convert that action to user code i have this method:
public static void Mouse_Click_ListItem2007_071()
{
//Your code here. Code inside this method will not be changed by the code generator.
Report.Info("Mouse Left Click item 'List1000.ListItem2007_07' at 50;3.");
repo.List1000.ListItem2008_011.Click("50;3");
}
But i need to receiving a date "2008/11" by a string i need to do the same but using code, without using record.It's possible?
I'm using Ranorex last version at this moment and i need to ask you a question.
I have 1 List Item where i need to select and click on a certain date i.e "2008/11" if i do that using the recorder and convert that action to user code i have this method:
public static void Mouse_Click_ListItem2007_071()
{
//Your code here. Code inside this method will not be changed by the code generator.
Report.Info("Mouse Left Click item 'List1000.ListItem2007_07' at 50;3.");
repo.List1000.ListItem2008_011.Click("50;3");
}
But i need to receiving a date "2008/11" by a string i need to do the same but using code, without using record.It's possible?
Last edited by rj-nora on Mon Jun 07, 2010 9:56 am, edited 1 time in total.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Select item on List Item using code
Hi,
You can write your own method for this behavior. I think the method in following post should work for you after some modifications.
http://www.ranorex.com/forum/how-to-sel ... -t998.html
Regards,
Peter
Ranorex Support Team
You can write your own method for this behavior. I think the method in following post should work for you after some modifications.
http://www.ranorex.com/forum/how-to-sel ... -t998.html
Regards,
Peter
Ranorex Support Team
Re: Select item on List Item using code
I still trying but with no success at this moment, can you show me a code snipet?
I have this code bellow not working...inside the if condition can i click on the option? How? With RanorexSpy i have the path for one date on the ComboBox : /form[@controlname='PPCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']/text[@accessiblevalue='2007/07']
public static void UserCodeMethod1()
{
string startDate = "{ListItem:2007/07}";
Ranorex.Form rtcForm = ("/form[@controlname='PPCMain']");
Ranorex.List RanorexList = rtcForm.FindSingle("/list[@controlid='1000']");
int count = RanorexList.Items.Count;
//Report.Error("Elementos da List Item"+ count);
foreach(Ranorex.ListItem fi in RanorexList.Items)
{
string f = fi.ToString();
//Report.Error(f);
if(f == startDate)
{
Report.Error("found item");
I have this code bellow not working...inside the if condition can i click on the option? How? With RanorexSpy i have the path for one date on the ComboBox : /form[@controlname='PPCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']/text[@accessiblevalue='2007/07']
public static void UserCodeMethod1()
{
string startDate = "{ListItem:2007/07}";
Ranorex.Form rtcForm = ("/form[@controlname='PPCMain']");
Ranorex.List RanorexList = rtcForm.FindSingle("/list[@controlid='1000']");
int count = RanorexList.Items.Count;
//Report.Error("Elementos da List Item"+ count);
foreach(Ranorex.ListItem fi in RanorexList.Items)
{
string f = fi.ToString();
//Report.Error(f);
if(f == startDate)
{
Report.Error("found item");
Last edited by rj-nora on Fri Jun 04, 2010 11:08 am, edited 3 times in total.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Select item on List Item using code
Hi,
I think following method is what you are searching for
Peter
Ranorex Support Team
I think following method is what you are searching for
public static void ClickItem(string strValue) { foreach( Ranorex.ListItem item in Ranorex.List.Items ) { if(item.Text == strValue) { item.Click(); } } }Regards,
Peter
Ranorex Support Team
Re: Select item on List Item using code
I will test it now, can you tell me if i can use the string = "2007/07" instead of {ListItem:2007/07} ?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Select item on List Item using code
Hi,
Just check the text with SPY, so you know the exact string of the list item.
Regards,
Peter
Ranorex Support Team
Just check the text with SPY, so you know the exact string of the list item.
Regards,
Peter
Ranorex Support Team
Re: Select item on List Item using code
the full path of the combobox is /form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']
and the path of one element is :
/form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']/text[@accessiblevalue='2009/51']
i tried this code bellow and it didn't work(Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'list'):
public static void ClickItem()
{
Ranorex.Form rtcForm = ("/form[@controlname='RTCMain']");
Ranorex.List RanorexList = rtcForm.FindSingle("/form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']");
string date = "{ListItem:2007/07}";
foreach( Ranorex.ListItem item in RanorexList.Items )
{
if(item.Text == date)
{
item.Click();
}
}
}
..
and the path of one element is :
/form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']/text[@accessiblevalue='2009/51']
i tried this code bellow and it didn't work(Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'list'):
public static void ClickItem()
{
Ranorex.Form rtcForm = ("/form[@controlname='RTCMain']");
Ranorex.List RanorexList = rtcForm.FindSingle("/form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']");
string date = "{ListItem:2007/07}";
foreach( Ranorex.ListItem item in RanorexList.Items )
{
if(item.Text == date)
{
item.Click();
}
}
}
..
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Select item on List Item using code
Hi,
Instead of
http://www.ranorex.com/Documentation/Ra ... mboBox.htm
Regards,
Peter
Ranorex Support Team
Instead of
use Ranorex.ComboBoxrj-nora wrote:Ranorex.List RanorexList = rtcForm.FindSingle("/form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']");
string date = "{ListItem:2007/07}";
http://www.ranorex.com/Documentation/Ra ... mboBox.htm
Ranorex.ComboBox RanorexList = rtcForm.FindSingle("/form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']");because you want to automate an combo box and not a list.
Regards,
Peter
Ranorex Support Team
Re: Select item on List Item using code
Hi! i have already tried and when i play the test nothings happens...
Code:
public static void ClickItem()
{
Ranorex.Form rtcForm = ("/form[@controlname='RTCMain']");
Ranorex.ComboBox RanorexList = rtcForm.FindSingle("/form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']");
string date = "2007/07";
foreach( Ranorex.ListItem item in RanorexList.Items )
{
string itemFound = item.ToString();
Report.Error(itemFound);
if(item.Text == date)
{
Report.Error("INSIDE");
item.Click();
}
}
}
Code:
public static void ClickItem()
{
Ranorex.Form rtcForm = ("/form[@controlname='RTCMain']");
Ranorex.ComboBox RanorexList = rtcForm.FindSingle("/form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']");
string date = "2007/07";
foreach( Ranorex.ListItem item in RanorexList.Items )
{
string itemFound = item.ToString();
Report.Error(itemFound);
if(item.Text == date)
{
Report.Error("INSIDE");
item.Click();
}
}
}
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Select item on List Item using code
Hi,
Please can you send us a Ranorex Snapshot.
http://www.ranorex.com/support/user-gui ... html#c2072
Or is it possible to send us the application to [email protected]
Regards,
Peter
Ranorex Support Team
Please can you send us a Ranorex Snapshot.
http://www.ranorex.com/support/user-gui ... html#c2072
Or is it possible to send us the application to [email protected]
Regards,
Peter
Ranorex Support Team
Re: Select item on List Item using code
Here is the snapshot
ComboBox'comboBoxWeekFrom' = /form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']
element '2009/52' = /form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']/text[@accessiblevalue='2009/52']
ComboBox'comboBoxWeekFrom' = /form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']
element '2009/52' = /form[@controlname='RTCMain']/container[@controlname='myTimeSel']/container/tabpagelist/tabpage[@controlname='tabFiscalWeek']/container/combobox[@controlname='comboBoxWeekFrom']/text[@accessiblevalue='2009/52']
You do not have the required permissions to view the files attached to this post.
Last edited by rj-nora on Fri Jun 04, 2010 12:23 pm, edited 1 time in total.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Select item on List Item using code
Hi,
There is no list below the combo box, this is the reason why you get this error
(Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'list').
I think you have first to open the combo box then the list will be generated. So please try to open the combo box before you execute the foreach statement.
Regards,
Peter
Ranorex Support Team
There is no list below the combo box, this is the reason why you get this error
(Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'list').
I think you have first to open the combo box then the list will be generated. So please try to open the combo box before you execute the foreach statement.
Regards,
Peter
Ranorex Support Team
Re: Select item on List Item using code
Thank you its starting to work
After do that on the Ranorex wrotte to the report every item like this :
2010/06/04 12:25:28.155 ERROR User {ListItem:1998/09}
2010/06/04 12:25:28.171 ERROR User {ListItem:1998/08}
But after that nothing happened...my string is string date = "2007/07"; the text[@accessiblevalue='2007/07'] i can't search for "2007/07"? it has to be {ListItem:1998/09}?
After do that on the Ranorex wrotte to the report every item like this :
2010/06/04 12:25:28.155 ERROR User {ListItem:1998/09}
2010/06/04 12:25:28.171 ERROR User {ListItem:1998/08}
But after that nothing happened...my string is string date = "2007/07"; the text[@accessiblevalue='2007/07'] i can't search for "2007/07"? it has to be {ListItem:1998/09}?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Select item on List Item using code
Hi,
Please check the string value of the list item with SPY and use following string value for your method.
Regards,
Peter
Ranorex Support Team
Please check the string value of the list item with SPY and use following string value for your method.
Regards,
Peter
Ranorex Support Team
Re: Select item on List Item using code
Thank you very much Problem solved 
