Selenium webdriver 使用WinAppDriver运行时,Outlook新电子邮件无法向元素发送密钥

Selenium webdriver 使用WinAppDriver运行时,Outlook新电子邮件无法向元素发送密钥,selenium-webdriver,outlook,automation,winappdriver,Selenium Webdriver,Outlook,Automation,Winappdriver,使用WinAppDriver时,我在尝试向新电子邮件窗口发送密钥时收到未知错误 我创建了一个新会话,用于与单击“新建电子邮件”时显示的新窗口进行交互。看起来元素与我使用时一样正确。单击() capabilities.setCapability("app", "Root"); driver = new WindowsDriver(new URL("http://127.0.0.1:4723"),capabilities ); driver.switc

使用WinAppDriver时,我在尝试向新电子邮件窗口发送密钥时收到未知错误

我创建了一个新会话,用于与单击“新建电子邮件”时显示的新窗口进行交互。看起来元素与我使用时一样正确。单击()

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

        driver.findElementByName("Page 1 content").sendKeys("PLEASE WORK!");
这就是我如何创建一个新会话来与出现的新窗口交互

Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'WVA01000004', ip: '10.200.153.43', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_212'
Driver info: io.appium.java_client.windows.WindowsDriver
Capabilities {app: Root, javascriptEnabled: true, platform: WINDOWS, platformName: WINDOWS}
下面是WinAppdriver的输出

==========================================
POST /session/4DC77131-E38D-4661-8544-B3A251D81D11/element HTTP/1.1
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 50
Content-Type: application/json; charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.59 (java windows)

{
  "using": "name",
  "value": "Page 1 content"
}

HTTP/1.1 200 OK
Content-Length: 99
Content-Type: application/json

{"sessionId":"4DC77131-E38D-4661-8544-B3A251D81D11","status":0,"value":{"ELEMENT":"42.787774.4.2"}}

==========================================
POST /session/4DC77131-E38D-4661-8544-B3A251D81D11/element/42.787774.4.2/value HTTP/1.1
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 64
Content-Type: application/json; charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.59 (java windows)

{
  "id": "42.787774.4.2",
  "value": [
    "PLEASE WORK!"
  ]
}

HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json

{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}

==========================================
DELETE /session/B4509E36-58DB-4E5A-BF02-F4143656262C HTTP/1.1
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 0
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.59 (java windows)



HTTP/1.1 200 OK
Content-Length: 12
Content-Type: application/json

{"status":0}


我确实读到有人使用
switchTo().activeElement()
使它工作,但这对我不起作用。

提到的问题已作为WinAppDriver()上的错误提出,但有解决问题的方法。这就是使用动作,下面是我用来解决问题的代码

    WebElement emailAddressInput = driver.findElementByName("To");
    WebElement subjectInput = driver.findElementByAccessibilityId("4100");
    WebElement locationInput = driver.findElementByAccessibilityId("4102");
    WebElement calendarBodyInput = driver.findElementByAccessibilityId("Body");

    Actions performAct = new Actions(driver);
    performAct.sendKeys(emailAddressInput, toText).build().perform();
    performAct.sendKeys(subjectInput, subjectText).build().perform();
    performAct.sendKeys(locationInput, locationText).build().perform();
    performAct.sendKeys(calendarBodyInput, bodyText).build().perform();

是否检查windappdriver会话是否为新窗口创建了新的windowhandle?如果是,您的问题很可能与所描述的问题和解决方案相似。您好,是的,我检查了windows会话句柄。我向WinAppDriver开发人员提出了这个问题,它已作为一个bug()提出。当前的解决方法是使用操作发送密钥。