1

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

我创建了一个新会话来与单击新建电子邮件时出现的这个新窗口进行交互。它看起来好像元素在我使用时是正确的。click() 然后测试将通过,但是当我尝试发送密钥时它失败了

        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()但这对我不起作用。

4

1 回答 1

1

提到的问题已作为 WinAppDriver ( https://github.com/microsoft/WinAppDriver/issues/775 ) 上的错误提出,但有解决该问题的方法。这是使用操作,下面是我用来解决问题的代码。

    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();
于 2019-08-13T14:15:18.633 回答