如何在守夜人中使用keys命令粘贴? [英] How to paste using the keys command in nightwatch?

查看:68
本文介绍了如何在守夜人中使用keys命令粘贴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何粘贴在守夜人中?我尝试了以下命令:

How can I paste in nightwatch? I tried this command:

browser.keys([browser.Keys.COMMAND, browser.Keys.v])

但是该命令不起作用.

理想情况下,我希望可以将复制的文本保存到变量中.

Ideally I would lake to be able to save the copied text into a variable.

推荐答案

我必须在 all 命令中添加第三个NULL参数,不仅是最后一个,而且还可以.可悲的是,我找不到任何有关其工作原理的文档.

I had to add the third NULL parameter to all commands, not only the last one, then it worked. Sadly, I can't find any documentation about how this exactly works.

我的用例是选择页面上所有带有图像(ctrl + a)的内容,将其复制(ctrl + v),然后导航到带有CKeditor的另一页面.专注于ckeditor并粘贴(ctrl + v)图像.

My usecase was selecting everything on a page with an image on it (ctrl+a), copying it (ctrl+v) and then navigating to another page with a CKeditor on it. Focussing on the ckeditor and pasting (ctrl+v) the image.

.keys([browser.Keys.CONTROL, 'a', browser.Keys.NULL])
.keys([browser.Keys.CONTROL, 'c', browser.Keys.NULL])
.keys([browser.Keys.CONTROL, 'v', browser.Keys.NULL])

这篇关于如何在守夜人中使用keys命令粘贴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆