SharpHook icon indicating copy to clipboard operation
SharpHook copied to clipboard

Automation QA- Trying to do a Tab>Enter>Tab>Enter to get rid of a dynamic popup during my Test Run

Open jthomas2021 opened this issue 2 years ago • 1 comments

Hi , During my automation testing, I encountered a popup that my Selenium libraries could not recognize - its a browser specific popup. The only way to get rid of it is to do a Tab , Enter, Tab , Enter and then it disappears and my test can continue. I am trying to use SharpHook to do these keystrokes(tab enter etc).

I used the below steps: var simulator = new EventSimulator();

simulator.SimulateKeyPress(SharpHook.Native.KeyCode.VcTab); simulator.SimulateKeyRelease(SharpHook.Native.KeyCode.VcTab);

On the simulator.SimulateKeyPress step, it catches below exception:

Unable to load DLL 'uiohook': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Please help me to resolve it.

Thanks

JT

jthomas2021 avatar Sep 29 '22 03:09 jthomas2021

Hi! Thanks for using SharpHook!

Could you please provide a little more info on the problem? I've never done AQA work on .NET - which project type are you using? You should look into the build output directory - uiohook.dll should be present there. If it's not, then this is the reason for the exception, and we will have to find out why it's not copied there. If it is present, well, then I can't really say right now why this exception happens.

Also, it would be ideal if you provide a small project where this issue could be reproduced.

TolikPylypchuk avatar Sep 29 '22 21:09 TolikPylypchuk

@jthomas2021 There hasn't been any activity in this issue for almost a month. I can't help you without more info so I'm going to close this issue in a few days if you don't provide any. We can continue the discussion after the issue is closed though if you decide to return to it.

TolikPylypchuk avatar Oct 25 '22 21:10 TolikPylypchuk

SharpHookWinFormTestDNF.zip here is a project with the same issue. Creating a bare bones dot net framework winform app with 4.8, adding sharphook via nuget, and creating a global hook and run. Dll is missing

JTtheGeek avatar Oct 26 '22 21:10 JTtheGeek

OK, I can reproduce this issue. I think it may be a general problem with .NET Framework-based projects (I've only ever tested on .NET 6). I'll see what can be done to fix this.

On an unrelated note, don't call hook.Run() in the form's constructor - it will block the UI thread and your UI won't ever show up.

TolikPylypchuk avatar Oct 27 '22 18:10 TolikPylypchuk

Turns out that .NET Framework-based projects don't copy native libraries from NuGet packages by default, and additional config in the package is required, as described in this StackOverflow page. I've previously added this config, but then removed it before releasing v1.0 thinking it wasn't needed. Well, it is needed, and I've added it back in version 3.1.3 which I've just released.

This should fix @JTtheGeek's problem. As for @jthomas2021's problem, I guess it's the same, but if you still encounter it, then let me know.

TolikPylypchuk avatar Oct 27 '22 20:10 TolikPylypchuk