我阅读了其他类似的问题,我只应单击该元素。
.then(myTextField => myTextField.click()
.then(_ => myTextField))
.then(myTextField=> myTextField.sendKeys(policyName)) // <<--- ERROR
上面的代码引发以下异常:
E/launcher - unknown error: cannot focus element
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)
[17:19:00] E/launcher - WebDriverError: unknown error: cannot focus element
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)
at Object.checkLegacyResponse (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebElement.sendKeys()
at thenableWebDriverProxy.schedule (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at WebElement.schedule_ (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\webdriver.js:2010:25)
at WebElement.sendKeys (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\webdriver.js:2174:19)
at actionFn (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\protractor\built\element.js:89:44)
at Array.map (<anonymous>)
at actionResults.getWebElements.then (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\protractor\built\element.js:461:65)
at ManagedPromise.invokeCallback_ (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:2927:27)Error
at ElementArrayFinder.applyAction_ (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\protractor\built\element.js:459:27)
at ElementArrayFinder.(anonymous function).args [as sendKeys] (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\protractor\built\element.js:91:29)
at ElementFinder.(anonymous function).args [as sendKeys] (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\protractor\built\element.js:831:22)
at elements.getElement.then.then.policyNameTextField (C:\GIT\nice-repositories\6.7_rh-front-end-automation\features\step_definitions\new-policy.js:39:58)
at ManagedPromise.invokeCallback_ (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\GIT\nice-repositories\6.7_rh-front-end-automation\node_modules\selenium-webdriver\lib\promise.js:668:7
at <anonymous>
如果需要任何其他信息,请告诉我。