如何使用量角器复制特定文本?
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 快捷方式.
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的剪贴板中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
即使在调用 abort (jQuery) 之后,浏览器也会等待Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在调用 abort (jQuery) 之后,浏览器也会等待 ajax 调用
JavaScript innerHTML 不适用于 IE?JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不适用于 IE?)
XMLHttpRequest 无法加载,请求的资源上不存在“AXMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 无法加载,请求的资
XHR HEAD 请求是否有可能不遵循重定向 (301 302)Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 请求是否有可能不遵循重定向 (301 302))
XMLHttpRequest 206 部分内容XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分内容)
XMLHttpRequest 的 getResponseHeader() 的限制?Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)