执行键盘击键"Ctrl + A"; " Ctrl + C"和"Ctrl + V"用硒C#在文本字段上 [英] Performing keyboard strokes "Ctrl + A" "Ctrl + C" and "Ctrl + V" on text field with selenium C#

查看:167
本文介绍了执行键盘击键"Ctrl + A"; " Ctrl + C"和"Ctrl + V"用硒C#在文本字段上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何简单地在文本框中输入值,使用"Ctrl + a"从文本框中选择完整的文本,然后使用"Ctrl + c"复制它,然后将其粘贴到同一框中Ctrl + v",使用Selenium + C#.

How to simply want to input a value in a text box , select the complete text from the text box using "Ctrl+a" , then copy it using "Ctrl + c" and then Paste it in the same box with "Ctrl + v" using Selenium + C#.

推荐答案

[FindsBy(How = How.Id, Using = "search-criteria")]
public IWebElement txtProductSearch1 = null

public void copypaste(string strCopy)
{ 
    txtProductSearch1.Click();
    txtProductSearch1.Clear();
    txtProductSearch1.SendKeys(strCopy);
    txtProductSearch1.SendKeys(Keys.Control + "a"); //a in smaller case
    txtProductSearch1.SendKeys(Keys.Control + "c"); // c in smaller case
    txtProductSearch1.Clear();
    txtProductSearch1.SendKeys(Keys.Control + "v"); // v in smaller case
    btnProductSearch1.Click();
}

这篇关于执行键盘击键"Ctrl + A"; " Ctrl + C"和"Ctrl + V"用硒C#在文本字段上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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