How i add text in a tag in e2e testing Angular Protractor(我如何在 e2e 测试 Angular Protractor 的标签中添加文本)
问题描述
我如何在
标签中添加内容以在量角器中进行 e2e 测试
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');
一个更大的问题是,因为这是一个 CKeditor - 它通常嵌入在 iframe
中.这对我们来说实际上很重要——我们需要让 webdriver 知道我们想要 切换到iframe
的上下文:
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');
这篇关于我如何在 e2e 测试 Angular Protractor 的标签中添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我如何在 e2e 测试 Angular Protractor 的标签中添加文本


基础教程推荐
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01