This question is locked. New answers and comments are not allowed.
Rajasekhar Chintha
Top achievements
Rank 1
Rajasekhar Chintha
asked on 17 Feb 2010, 07:13 AM
Hi,
I tried to access (Getting Items to check and selecting items using index or item name) for Combo box and List Box(Multi select element). But Items count is showing 0. Please help me how will you access and test a combo box or a list box in Silver light
Regards,
Raj
I tried to access (Getting Items to check and selecting items using index or item name) for Combo box and List Box(Multi select element). But Items count is showing 0. Please help me how will you access and test a combo box or a list box in Silver light
Regards,
Raj
7 Answers, 1 is accepted
0
Hi Rajasekhar,
Here is some sample code you can try for a ComboBox:
Note that the ComboBox Items must be made visible in order for the framework to populate them in the ComboBox wrapper class.
Please post back if you have nay questions on this.
Kind regards,
Nelson Sin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Here is some sample code you can try for a ComboBox:
[TestMethod] public void SampleWebAiiTest() { // Launch a browser instance Manager.LaunchNewBrowser(BrowserType.InternetExplorer); // The active browser ActiveBrowser.NavigateTo("http://silverlight.net/content/samples/sl2/silverlightcontrols/run/default.html"); // Get reference to Silverlight app SilverlightApp app = ActiveBrowser.SilverlightApps()[0]; // Get and click on ComboBox link TextBlock b = app.Find.ByText("ComboBox"); b.User.Click(MouseClickType.LeftClick); // Get and click on first ComboBox ComboBox c = app.Find.ByType<ComboBox>(); c.User.Click(MouseClickType.LeftClick); //After making ComboBox Items visible, refresh the ComboBox container c.Refresh(); // Select the ComboBox Item index c.SelectedIndex = 5; // Close the ComboBox c.User.Click(MouseClickType.LeftClick); }Note that the ComboBox Items must be made visible in order for the framework to populate them in the ComboBox wrapper class.
Please post back if you have nay questions on this.
Kind regards,
Nelson Sin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rajasekhar Chintha
Top achievements
Rank 1
answered on 19 Feb 2010, 05:31 AM
Thanks Nelson Sin for quick reply. As you said, a Combo box can be accessible but not list box(An object which allows user to select more than 1 Item using Ctrl button). I want get list of Items which are selected and I want to select different Items in the list. How can I do this.
Please explain.
Regards,
Rajasekhar
Please explain.
Regards,
Rajasekhar
0
Hello again Rajasekhar,
Here is sample code based on a SL 3 DataGrid with multi select. You can do something similar for your control:
The main part is clicking on the rows you want selected inbetween having the KeyDown and KeyUp for the Control key.
Hope that helps,
Nelson
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Here is sample code based on a SL 3 DataGrid with multi select. You can do something similar for your control:
public void MultiSelectExample() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo("http://silverlight.net/content/samples/sl3/toolkitcontrolsamples/run/default.html"); SilverlightApp app = ActiveBrowser.SilverlightApps()[0]; app.Find.ByText("DataGrid").User.Click(MouseClickType.LeftClick); app.VisualTree.Refresh(); DataGrid g = app.Find.ByExpression(new XamlFindExpression("AutomationId=dataGrid", "XamlTag=datagrid")).As<DataGrid>(); RepeatButton b = g.Find.ByExpression(new XamlFindExpression("name=VerticalLargeIncrease", "automationid=VerticalLargeIncrease")).As<RepeatButton>(); b.UserPress(2000); b.UserPress(500); g.Refresh(); DataGridRow ult = g.Rows[g.Rows.Count - 1]; ult.User.Click(); Desktop.KeyBoard.KeyDown(System.Windows.Forms.Keys.ControlKey); DataGridRow penUlt = g.Rows[g.Rows.Count - 2]; penUlt.User.Click(); Desktop.KeyBoard.KeyUp(System.Windows.Forms.Keys.ControlKey); }The main part is clicking on the rows you want selected inbetween having the KeyDown and KeyUp for the Control key.
Hope that helps,
Nelson
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rajasekhar Chintha
Top achievements
Rank 1
answered on 22 Feb 2010, 06:04 AM
Hi,
Selecting the items using row number is not an efficient way in automation. I want select items using item names(Items.Content). Is it possible? Also I did not see the code to get the information about selected elements. If I want test How many elements were selected and what are the elements selected, How can I do this?
Regards,
Rajasekhar
Selecting the items using row number is not an efficient way in automation. I want select items using item names(Items.Content). Is it possible? Also I did not see the code to get the information about selected elements. If I want test How many elements were selected and what are the elements selected, How can I do this?
Regards,
Rajasekhar
0
Hello again Rajasekhar,
So I used index since the grid example dynamically populates it's text and I don't know what it will be.
But if you know the text you want to click, you should be able to do something like this, based on the the code I posted earlier and over the currently visible cells in the data grid:
The code I posted selected the last and next to last rows. User.Click() is actually clicking on the rows in the previous code and the cells in the above code.
In order to test the code, you can use the WebAii templates in a VS test project that are under: Add -> Add New Item -> Expand Test Node -> WebAii 2.0 -> VsUnit.
Hope that helps,
Nelson
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
So I used index since the grid example dynamically populates it's text and I don't know what it will be.
But if you know the text you want to click, you should be able to do something like this, based on the the code I posted earlier and over the currently visible cells in the data grid:
g.Refresh(); Desktop.KeyBoard.KeyDown(System.Windows.Forms.Keys.ControlKey); g.Find.ByText("CellOneText").User.Click(); g.Find.ByText("CellTwoText").User.Click(); Desktop.KeyBoard.KeyUp(System.Windows.Forms.Keys.ControlKey);The code I posted selected the last and next to last rows. User.Click() is actually clicking on the rows in the previous code and the cells in the above code.
In order to test the code, you can use the WebAii templates in a VS test project that are under: Add -> Add New Item -> Expand Test Node -> WebAii 2.0 -> VsUnit.
Hope that helps,
Nelson
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rajasekhar Chintha
Top achievements
Rank 1
answered on 22 Feb 2010, 05:02 PM
Hi,
Thanks for your reply. If I want to test what are the elements selected, how can I verify? Please explain.
Regards,
Rajasekhar
Thanks for your reply. If I want to test what are the elements selected, how can I verify? Please explain.
Regards,
Rajasekhar
0
Hi again Rajasekhar,
So the SelectedIndex property in the DataGrid reference will change to the absolute index within the DataGridRow.
Also, from the last code I posted, you can also verifiy that the color has changed for the cell being selected:
Hope that helps,
Nelson
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
So the SelectedIndex property in the DataGrid reference will change to the absolute index within the DataGridRow.
Also, from the last code I posted, you can also verifiy that the color has changed for the cell being selected:
TextBlock b = g.Find.ByText("CellOneText"); b.User.Click();
DataGridCell selectedCell = b.Parent<DataGridCell>(); SolidColorBrush selectionColor = selectedCell .Background as SolidColorBrush; // Here use the selectionColor.Color for verificationHope that helps,
Nelson
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.