This is a migrated thread and some comments may be shown as answers.

WPF ComboBox Popup element Catch

6 Answers 267 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
asked on 19 Oct 2018, 10:05 AM

我想問一下這個WPF ComboBox如何獲取它的Item,

我從Snoop Tool檢查了它的xaml,並了解到當前應用程序Xaml中不存在Popup的內容。

這個問題就像日期選擇器

我正在使用Testing Framework Automation編寫C#測試腳本

 

謝謝


6 Answers, 1 is accepted

Sort by
0
Top achievements
Rank 1
answered on 22 Oct 2018, 03:07 AM

I have found a solution

var testComboBox = window[3].Find.ByName("testComboBox").CastAs<ComboBox>();
testComboBox.OpenDropDown(true);
testComboBox.SelectItemByIndex(true, 0, false);
Thread.Sleep(1000);
mgsApp.MainWindow.RefreshVisualTrees();

 

The new problem is to click on the "magnifying glass" to select the folder location, how to grab its elements to do the operation

I hope that future teaching documents can provide more examples.Thanks

0
Elena
Telerik team
answered on 24 Oct 2018, 09:58 AM
Hello,

Thank you for your feedback about the documentation. I guess you have used the exposed APIs description to find the shared solution. If you have found any other resources, please let me know. 

In regards the current issue you have encountered in handling the dialog which opens a folder, I would like to share with you how Win32 dialogs can be handled with the Testing famework.

You probably have noticed that the OpenFolderDialog is a bit different from the other Win32 dalogs and is not present in the above shared article. This is because its structure does not suppose providing directly a folder path to handle that. The dialog from the screenshot does not have any text field to pass a folder path and is being handled with clicks or key presses even when doing this manually.

Having that said, to be able to automate the actions against that dialog you will need to send desktop actions against the currently active element. In Test Studio you can accomplish that using the Desktop Manager and its KeyBoard manager class. Then, similar to this example, send the necessary keystrokes to navigate to the desired folder.

If we take the example from the screenshot, assuming the folder to choose is the selected one - Dokumente - you might need to press Tab key once or twice to change the focus on the OK button. Then pressing the Enter key will confirm the selected path. To cover the scenario correctly you can try first manually what is the combination of keyboard key presses to navigate to the desired folder and then change the focus on the OK button to confirm the selection.

Having the example from the screenshot the below code will select the first sub-folder under the root one, assuming the focus currently is on that root folder. And then confirm the selection. The sample code will look similar to that below:

// The focus is on the root folder. Pressing Enter will expand it
Manager.Desktop.KeyBoard.KeyPress(Keys.Enter);
// Pressing the down arrow will move the active element to the first sub-folder in the expanded root folder
Manager.Desktop.KeyBoard.KeyPress(Keys.Down);
// Pressing Tab will change the focus to any of the buttons Ok, Cancel or Create new folder
// In this example I assume a single Tab press sets focus on the Ok button
Manager.Desktop.KeyBoard.KeyPress(Keys.Tab);
// Pressing Enter confirm the selection
Manager.Desktop.KeyBoard.KeyPress(Keys.Enter);

Of course, the above sample is based on assumptions as I am not aware of the exact consequences of key presses required and thus you will need to additionally adjust it. Please have in mind that for the above code you will need to add an assembly reference in the project to System.Windows.Forms.dll, as well as list a using statement to it.

I hope this will be helpful to you. Though, if you need further assistance, please let me know.

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Top achievements
Rank 1
answered on 25 Oct 2018, 05:46 AM
Thank you, your suggestion is very helpful for my work.
0
Elena
Telerik team
answered on 25 Oct 2018, 02:10 PM
Hi,

I am glad to hear my recommendations were helpful. In case of further questions, please reach out back to us. Thanks.

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Top achievements
Rank 1
answered on 05 Nov 2018, 02:56 AM

How can I get the MSI offline installation package of Testing-Framework?

 

I have tried to search the relevant topics on the forums and follow the steps. I still can't download the msi file.

Screenshot of the personal account download page on the attachment.

https://www.telerik.com/forums/offline-installer-for-test-framework

https://www.telerik.com/forums/offline-installer-bdfff74f26d1

Can you provide cloud space for msi files to me? Thank you.

0
Elena
Telerik team
answered on 07 Nov 2018, 03:33 PM
Hello,

This link here will download the Progress Installer on your machine. Then, you can start the download and installation of the latest Testing Framework. This can be accomplished on a machine which has internet access.

Though, it seems you need to install the Framework on an offline machine. To do that, please open the following folder C:\ProgramData\Progress\Installer\Downloads on the first machine which has access to the internet and you have downloaded the above package. There you should find the downloaded Testing Framework exe file which can be seamlessly installed on any other machine regardless if it is off- or online. 

Please let me know if you need further assistance.

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Elena
Telerik team
Share this question
or