Text in clipboard with protractor js(带有量角器js的剪贴板中的文本)
问题描述
如何使用量角器复制特定文本?
How can I copy a specific text with protractor ?
我想使用此命令加载要粘贴的文本:
I would like to load a text to paste after with this command :
return browser.actions().sendKeys(Keys.CONTROL, 'v').perform();
示例:
加载我的文本test",然后使用此命令粘贴test"
Load my text "test" and after with this command, paste "test"
我想在我的剪贴板中放一个文本
I would like put a text in my clipboard
推荐答案
我可以直接在我的 ng-model 中输入一个值,而不是使用 sendKeys 吗?
can I put a value directly in my ng-model, not use sendKeys ?
是的,您可以通过 model 值="nofollow noreferrer">.evaluate():
Yes, you can directly set the model value via .evaluate():
var elm = element(by.model("mymodel.field"));
elm.evaluate("mymodel.field = 'test';");
将文本放入剪贴板
这个想法是使用现有的或动态创建一个 input 元素,您可以将文本发送到该元素,选择输入中的所有文本并使用 CTRL/COMMAND + 复制它C 快捷方式.
Putting a text into clipboard
The idea is to use an existing or dynamically create an input element where you would send the text to, select all the text in the input and copy it with a CTRL/COMMAND + C shortcut.
示例:
var textToBeCopied = "my text";
// creating a new input element
browser.executeScript(function () {
var el = document.createElement('input');
el.setAttribute('id', 'customInput');
document.getElementsByTagName('body')[0].appendChild(el);
});
// set the input value to a desired text
var newInput = $("#customInput");
newInput.sendKeys(textToBeCopied);
// select all and copy
newInput.sendKeys(protractor.Key.chord(browser.controlKey, "a"));
newInput.sendKeys(protractor.Key.chord(browser.controlKey, "c"));
其中 browser.controlKey 是处理 CTRL/COMMAND 键的跨平台方式:
where browser.controlKey is a cross-platform way to handle CTRL/COMMAND keys:
- 使用跨平台键盘快捷键结束-端到端测试
这篇关于带有量角器js的剪贴板中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有量角器js的剪贴板中的文本
基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
