简体   繁体   中英

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

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');

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM