UnknownError: null protractor

UnknownError: null protractor

我关注this tutorial

除了根据
,我遵循了其他步骤 而不是

npm install -g protractor

我申请了

npm install -g protractor --no-optional

我成功完成了Step 0 - write a test

expect(browser.getTitle()).toEqual('Super Calculator');

但是当我尝试 Step 1 - interacting with elements

element(by.model('first')).sendKeys(1);

它给出错误:

Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
F

Failures:

  1) Protractor Demo App should add one and two
   Message:
     UnknownError: null
   Stacktrace:
     UnknownError: null
   //... continue stack trace

我可以看到我可以通过测试访问 dom 元素:

element(by.model('firstXXX')).sendKeys(1);

然后它说,

NoSuchElementError: No element found using locator: by.model("firstXXX")

上述错误信息可能是什么原因:

Message:
     UnknownError: null

也从 webdriver-manager start 控制台输出:

16:41:27.526 INFO - Executing: [send keys: null null, [1]])
16:41:27.527 WARN - Exception thrown
java.lang.NullPointerException
        at org.openqa.selenium.remote.server.handler.SendKeys.call(SendKeys.java:49)
        at org.openqa.selenium.remote.server.handler.SendKeys.call(SendKeys.java:1)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession.run(DefaultSession.java:168)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
16:41:27.530 WARN - Exception: null
16:41:27.658 INFO - Executing: [delete session: 157e0397-52e0-4d03-b8ee-aef453cd83a2])
16:41:28.843 INFO - Done: [delete session: 157e0397-52e0-4d03-b8ee-aef453cd83a2]

您应该在使用 seleniumAddress 时解决您的问题,但您也可以使用 directConnect 自动化 Chrome 和 Firefox,示例配置为 here.