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

Cannot click WPF RadRibbonButton.

7 Answers 181 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tetsu
Top achievements
Rank 1
Tetsu asked on 08 Mar 2019, 07:09 PM

Hi,

I'd like to test a WPF app that uses Telerik UI for WPF. I downloaded the Testing Framework. But I can't seem to click a RadRibbonButton by calling "button.User.Click()" method, even though the "button" variable seems to correctly point to the button:

using ArtOfTest.WebAii.Silverlight;
using ArtOfTest.WebAii.TestTemplates;
using Telerik.WebAii.Controls.Xaml.Wpf;

namespace UnitTestProject1
{
    public class MainWindow : XamlElementContainer
    {
        public MainWindow(VisualFind find)
            : base(find)
        {
        }

        public void ClickSave()
        {
            const string Path =
                "XamlPath=/Grid[0]/Grid[0]/Grid[0]/AdornerDecorator[0]/ContentPresenter[0]/RadRibbonView[0]/Grid[0]/Grid[0]/ContentPresenter[0]/Grid[0]/RibbonScrollViewer[0]/Grid[0]/ContentPresenter[0]/ItemsPresenter[0]/RibbonGroupsPanel[0]/RadRibbonGroup[0]/Grid[0]/GroupChrome[0]/Border[0]/Grid[0]/ContentPresenter[0]/ItemsPresenter[0]/RibbonButtonsPanel[0]/RadRibbonButton[1]";
            var button = this.Get<RadRibbonButton>(Path);
            button.User.Click();
        }
    }
}


I attach a sample project that demonstrate this behavior.

I'd appreciate any suggestions.

Thanks,

Tetsu

7 Answers, 1 is accepted

Sort by
0
Tetsu
Top achievements
Rank 1
answered on 10 Mar 2019, 12:09 AM
I was able to solve the problem. For some reason, the processor architecture of the unit test project was set to x64. I was using ReSharper unit testing with MSTest. Changing ReSharper's setting <Resharper/Options/Tools/Unit Testing/General/Default platform architecture> to Automatic allowed the Click() method to run as expected. When using Visual Studio's Test, the setting <Test/Test Settings/Default Processor Architecture> needed to be x86.

0
Tetsu
Top achievements
Rank 1
answered on 11 Mar 2019, 06:13 PM

I further tracked down why it didn't work with X64. Turns out that ArtOfTest.WebAii.Win32.Win32NativeMethods.SendInputInternal(inputData) failed when simulating the mouse click. Does it have something to do with the following StackOverflow question - https://stackoverflow.com/questions/6830651/sendinput-and-64bits?

It's preferable that the framework can work in X64 mode because of some other tool that I'm using in the same test project to support Win32 dialog boxes.

0
Plamen Mitrev
Telerik team
answered on 13 Mar 2019, 03:25 PM
Hello Tetsu,

I understand that you have resolved the issue already. I just want to confirm that Test Studio Framework is a 32 bit process and when you initially built your test with a 64 bit setting, this was causing the misbehavior.

I also want to add that the topic of the article is not related to Test Studio as it is a 32 bit process.

Thank you for digging in and finding a solution to the issue. Please do not hesitate to contact us again if you have any further questions about Testing Framework usage.

Regards,
Plamen Mitrev
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Tetsu
Top achievements
Rank 1
answered on 13 Mar 2019, 04:16 PM

Hi Plamen,

Thanks for the reply. I'm in the process of purchasing a support license for the framework. But, would you be able to fix the Win32NativeMethods class in the next update so that it can support both 32 and 64 bit environment? I suppose it's not a difficult task. The reason I'm trying to use some other library together with the framework is that the framework does not support Win32 dialog boxes. The library I'm using is called FlaUi. Unfortunately, it has its own bugs and only works in 64 bit mode. So, I can't use the two at the same time...

Tetsu

0
Plamen Mitrev
Telerik team
answered on 18 Mar 2019, 02:48 PM
Hello Tetsu,

Thank you for your question and for sharing details regarding your scenario.

It is possible to use System.Windows.Forms to call for mouse click and keyboard press events, instead of the User.Click(), which is causing some issues. The framework and Test Studio is not designed to run as a 64bit application, because we encountered some limitations when we evaluated this change before.

I am sorry to let you know, that it is not possible to make the change at this point, but you can try the suggestion above and I will investigate further for another possible solution for you.

Than you for your understanding.

Regards,
Plamen Mitrev
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Tetsu
Top achievements
Rank 1
answered on 18 Mar 2019, 03:00 PM

Hi Plamen,

>The framework and Test Studio is not designed to run as a 64bit application, because we encountered some limitations when we evaluated this change before.

In that case, please don't bother anymore. I'll use the framework in 32 bit mode. And now I know how to deal with Win32 dialog boxes thanks to your help.

Thanks anyways.

 

0
Plamen Mitrev
Telerik team
answered on 20 Mar 2019, 04:05 PM
Hello Tetsu,

I am glad to know that you are able to handle the dialog boxes, which were causing you troubles.

Thank you for your understanding and do not hesitate to contact us in the future.

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