WinAppDriver OutLook New Email Elements not found

狂风中的少年 提交于 2020-01-25 07:26:26

问题


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.

回答1:


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




回答2:


switchTo().activeElement() didn't work for me so I had to create a new session to interact with the elements on the new email page. Hopefully, this helps others who had the same issue as me

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("app", "Root");
    driver = new WindowsDriver<>(new URL("http://127.0.0.1:4723"), capabilities);


来源:https://stackoverflow.com/questions/45998532/winappdriver-outlook-new-email-elements-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!