How i add text in a tag in e2e testing Angular Protractor

不羁的心 提交于 2019-12-30 14:24:51

问题


how i add content in

tag for e2e testing in protractor

<html lang="en" dir="ltr">
 <head>
  <body class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" contenteditable="true" spellcheck="true">
   <p>
     <br type="_moz">
   </p>
 </body>
</html>

i try this but this is not working

var p = element(by.css('.cke_editable p'));
p.sendKeys('This is a peragraph tag');

回答1:


First of all, it is the body that's editable in this case - send keys to it:

var body = element(by.css('body.cke_editable'));
body.sendKeys('This is a paragraph tag');

A bigger problem though is that, since this is a CKeditor - it's usually embedded in an iframe. This is actually important for us - we need to let the webdriver know that we want to switch into the context of the iframe:

browser.switchTo().frame(element(by.css("iframe.cke_wysiwyg_frame")));

var body = element(by.css('body.cke_editable'));
body.sendKeys('This is a paragraph tag');


来源:https://stackoverflow.com/questions/33519647/how-i-add-text-in-a-tag-in-e2e-testing-angular-protractor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!