尝试使用WinAppDriver模拟(自动化)通过outlook发送的电子邮件,识别“新电子邮件”元素并打开新窗口但在新窗口中无法识别“收件人”,“CC”等控件。
我怀疑新的Windows会话不适用于驱动程序。
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.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.最满意答案
我认为您面临的问题是因为Outlook将为您的新电子邮件创建一个新的Windows。 这将导致窗口不属于您当前的会话。 解决此问题的最佳方法是创建桌面会话,找到新窗口,然后附加新会话,然后从那里控制新窗口。
希望这可以帮助。
吉尔斯·〜
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
更多推荐
发布评论