Search code examples
outlookautomationwinappdriver

WinAppDriver OutLook New Email Elements not found


Trying to mimic (automate) email sending through outlook using WinAppDriver, the "New E-mail" element is recognized and new window opens but on the new Window the "To","CC" etc controls are not recognized.

I suspect the new windows session is not available for the driver.

try {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setPlatform(Platform.WIN10);
    //capabilities.setCapability("appTopLevelWindow", "0xBB880A");
    capabilities.setCapability("app", "C:\\Program Files\\Microsoft Office\\Office14\\OUTLOOK.exe");
        outlookSession = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
            outlookSession.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        newEmail = outlookSession.findElementByName("New E-mail");
        System.out.println("newEmail:::::: " + newEmail);
        newEmail.click();

        outlookSession.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

        outlookSession.findElementByName("To").sendKeys("<email>"); (the 'To' element is not recognized.

Solution

  • I think that the problem you are facing is cause by the fact that Outlook will create a new Windows for your new email. That will result in the window not being part of your current session. The best way to address this, is probably creating a desktop session, finding your new window and then attaching a new session and then controlling your new window from there.

    Hope this helps.

    ~Gilles