How to write Protractor test for ui-codemirror AngularJS directive? -
i using ui-codemirror angularjs directive in project , write protractor test (devopshammer/src/test/webapp/e2e/json-spec.js) adds input it.
finding element it's model (ng-model attribute) returns ui-codemirror element, not possible use sendkeys() method add input (neither on it's child element).
does have hint how that?
stacktrace:
failures: 1) json formatter shuld 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: server did not provide 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: server did not provide 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 @ new bot.error (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113:18) @ object.bot.response.checkresponse (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:106:9) @ c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:377:20 @ [object object].promise.controlflow.runinframe_ (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20) @ [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) @ [object object].promise.promise.notify_ (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:563:12) @ array.foreach (native) @ object.goog.array.foreach (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\array\array.js:203:43) @ [object object].promise.promise.notifyall_ (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:552:16) @ 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 @ [object object].elementarrayfinder.applyaction_ (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\lib\element.js:408:21) @ [object object].self.(anonymous function) [as sendkeys] (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\lib\element.js:76:19) @ [object object].self.(anonymous function) [as sendkeys] (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\lib\element.js:736:11) @ [object object].<anonymous> (c:\projects\devopshammer-master\src\test\webapp\e2e\json-spec.js:25:40) @ c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\jasminewd\index.js:94:14 @ [object object].promise.controlflow.runinframe_ (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20) @ [object object].promise.controlflow.runeventloop_ (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1755:8) @ [object object].<anonymous> (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:2056:12) @ 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() @ [object object].<anonymous> (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\jasminewd\index.js:93:33) @ [object object].<anonymous> (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\async-callback.js:45:37) @ [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) @ [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) @ [object object]._ontimeout (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2199:18) error @ [object object].<anonymous> (c:\projects\devopshammer-master\src\test\webapp\e2e\json-spec.js:22:5) @ [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) @ [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) @ describe (c:\users\212412346\appdata\roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:658:27) @ object.<anonymous> (c:\projects\devopshammer-master\src\test\webapp\e2e\json-spec.js:1:63)
template code:
<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>
test code:
it('shuld 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(); });
you can solve with:
browser.executescript("var editor = $('.codemirror')[0].codemirror;editor.setvalue('{');");
Comments
Post a Comment