[英]How i add text in a tag in e2e testing Angular Protractor
how i add content in 我如何在其中添加内容
tag for e2e testing in protractor 用于量角器的e2e测试的标签
<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
. 不过,更大的问题是,由于这是CKeditor-通常嵌入在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
: 这实际上对我们很重要-我们需要让Webdriver知道我们想切换到 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');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.