プロジェクトで ui-codemirror AngularJS ディレクティブを使用しており、入力を追加する分度器テスト (devopshammer/src/test/webapp/e2e/json-spec.js) を作成したいと考えています。
モデル (ng-model 属性) で要素を検索すると ui-codemirror 要素が返されますが、sendKeys() メソッドを使用して入力を追加することはできません (その子要素にもありません)。
誰もそれを行う方法のヒントを持っていますか?
スタックトレース:
Failures:
1) json formatter shuld say error message when invalid input
Message:
UnknownError: unknown error: cannot focus element
(Session info: chrome=43.0.2357.81)
(Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 24 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'HCE-F9HBD12', ip: '3.183.12.101', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=C:\Users\212412~1\AppData\Local\Temp\scoped_dir7296_19054}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=43.0.2357.81, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}
Session ID: fffb7bec66f225f772bd998c9bc9c364
Stacktrace:
UnknownError: unknown error: cannot focus element
(Session info: chrome=43.0.2357.81)
(Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 24 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'HCE-F9HBD12', ip: '3.183.12.101', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=C:\Users\212412~1\AppData\Local\Temp\scoped_dir7296_19054}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=43.0.2357.81, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}
Session ID: fffb7bec66f225f772bd998c9bc9c364
at new bot.Error (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113:18)
at Object.bot.response.checkResponse (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:106:9)
at C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:377:20
at [object Object].promise.ControlFlow.runInFrame_ (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20)
at [object Object].promise.Callback_.goog.defineClass.notify (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:2464:25)
at [object Object].promise.Promise.notify_ (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:563:12)
at Array.forEach (native)
at Object.goog.array.forEach (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\array\array.js:203:43)
at [object Object].promise.Promise.notifyAll_ (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:552:16)
at goog.async.run.processWorkQueue (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:125:21)
Error
at [object Object].ElementArrayFinder.applyAction_ (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\lib\element.js:408:21)
at [object Object].self.(anonymous function) [as sendKeys] (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\lib\element.js:76:19)
at [object Object].self.(anonymous function) [as sendKeys] (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\lib\element.js:736:11)
at [object Object].<anonymous> (c:\projects\devopshammer-master\src\test\webapp\e2e\json-spec.js:25:40)
at C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd\index.js:94:14
at [object Object].promise.ControlFlow.runInFrame_ (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20)
at [object Object].promise.ControlFlow.runEventLoop_ (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1755:8)
at [object Object].<anonymous> (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:2056:12)
at goog.async.run.processWorkQueue (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:125:21)
From: Task: Asynchronous test function: it()
at [object Object].<anonymous> (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd\index.js:93:33)
at [object Object].<anonymous> (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\async-callback.js:45:37)
at [object Object].jasmine.Block.execute (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:1174:17)
at [object Object].jasmine.Queue.next_ (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2209:31)
at [object Object]._onTimeout (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2199:18)
Error
at [object Object].<anonymous> (c:\projects\devopshammer-master\src\test\webapp\e2e\json-spec.js:22:5)
at [object Object].jasmine.Env.describe_ (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:913:21)
at [object Object].jasmine.Env.describe (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:898:15)
at describe (C:\Users\212412346\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:658:27)
at Object.<anonymous> (c:\projects\devopshammer-master\src\test\webapp\e2e\json-spec.js:1:63)
テンプレート コード:
<div ng-show="hasInvalidContent()" class="alert alert-danger" role="alert">INVALID {{message}}</div>
<div>
<p>
<ui-codemirror class="text-left"
ui-codemirror-opts="editorOptions"
ng-model="jsonInput"></ui-codemirror>
</p>
<p>
<input id="formatJsonButtonId"
type="button"
class="btn btn-primary"
ng-click="jsonInputChange()"
value="Format"/>
</p>
</div>
テストコード:
it('shuld say error message when invalid input', function () {
var messageError = element(by.css('div.alert-danger'));
element(by.model('jsonInput')).sendKeys('{');
element(by.id('formatJsonButtonId')).click();
expect(messageError.isDisplayed()).toBeTruthy();
});