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

Answers:

Answer

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

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.