I am creating a wpf test that changes the selected item of a listbox, but restores it back to it's original value when the test is complete. Is there mechanism to save the selectedIndex into a vairable and then use it again later in the test?
Now that I went to the trouble to ask the question, I did finally solve the problem myself.
1) In a coded step I used
var selectedIndex = ActiveApplication.MainWindow.Find.ByAutomationId<RadListBox>("LanguageListbox").SelectedIndex; SetExtractedValue("LanguageListBoxItem", selectedIndex);
2) Then I created a VariableListboxItem Element that I bound the SelectedIndex to the "LanguageListBoxItem" variable.
3) I was then able to add an action to select a list item, and then I changed the element it was using to the "VariableListBoxItem".
answered on 05 Apr 2022, 01:37 PM
I am happy to know that you found a solution in coded step on your own.
I wanted to add that you can record an Extract step that will create the runtime variable (with the coded step). Then, you can use the extracted value as data binding for other steps in the same test or test as step. It would be the preferred approach for someone that does not want to use coded steps in their test, as this covers the basic scenario.
Thank you for starting this discussion and sharing the solution you used!
Does UI testing really fit into CI/CD?
If you want to find out how to take advantage of continuous delivery pipelines, join our Test Studio webinar on Wednesday, April 6 at 11 am EST | 5 pm CET.