Search code examples
unit-testingappiumui-automationwinappdriver

How to create a session for Run Dialog in Appium?


By using powershell command I can get the run dialog program id, which is Microsoft.Windows.Shell.RunDialog. However, I can't get this working with the code below. Any idea?

DesiredCapabilities desktopCapabilities = new DesiredCapabilities();
desktopCapabilities.SetCapability("app", "Microsoft.Windows.Shell.RunDialog");
desktopCapabilities.SetCapability("deviceName", "WindowsPC");
desktopCapabilities.SetCapability("platformName", "Windows");

session = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), desktopCapabilities);

Solution

  • Take a look at the answers from this post about the run dialog. My best guess is that winappdriver is calling rundll32.exe and that's not the dialog itself.

    You could try your luck changing this line

    desktopCapabilities.SetCapability("app", "Microsoft.Windows.Shell.RunDialog");
    

    into

    desktopCapabilities.SetCapability("app", "c:\windows\system32\rundll32.exe shell32.dll,#61");
    

    Alternatively, you could get the desktop session and send "windows key + r" to it. Here is how you can get the desktop session.