Is it possible to copy and paste with webdriver?

11,758 views
Skip to first unread message

ei0haro

unread,
Jul 22, 2011, 8:13:01 AM7/22/11
to webdriver
Hi!

I have a scenario I want to test where I need to copy and paste a node
in a treeview by using the keyboard combination Ctrl + C, Ctrl + V.
(In Internet Explorer)

But how do I perform that with webdriver?

The following did not work for the latest webdriver release V2.1 for
C#.

var action = new Actions(webDriver);
action.Click(nodeElement)
.KeyDown(nodeElement, Keys.LeftControl)
.SendKeys(nodeElement, "c")
.KeyUp(nodeElement, Keys.LeftControl)
.KeyDown(nodeElement, Keys.LeftControl)
.SendKeys(nodeElement, "v")
.KeyUp(nodeElement, Keys.LeftControl)
.Build()
.Perform();

Simon Stewart

unread,
Jul 22, 2011, 9:02:51 AM7/22/11
to webd...@googlegroups.com
SendKeys(Keys.LeftControl + "a");
SendKeys(Keys.LeftControl + "c");
SendKeys(Keys.LeftControl + "v");

should work

Simon

> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>
>

ei0haro

unread,
Jul 22, 2011, 9:30:36 AM7/22/11
to webdriver
That worked very well.
Thanks alot!

Mark Collin

unread,
Jul 22, 2011, 9:56:37 AM7/22/11
to webd...@googlegroups.com
You may want to put some logic in to deal with OSX if you are going to be
running this cross browser (You'll need to use CMD + C and CMD + V in that
case.


--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

If you have received this email in error please notify postm...@ardescosolutions.com

Mark Collin

unread,
Jul 22, 2011, 9:57:05 AM7/22/11
to webd...@googlegroups.com
Any chance of a OS independent copy / paste command in the future?

-----Original Message-----
From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On

should work

Simon

Pushpraj Singh

unread,
Nov 12, 2012, 2:47:14 AM11/12/12
to webd...@googlegroups.com
But how can we perform copy + paste of selected text and give it in SendKeys("____paste copied text here________");
what I want to achieve here is :

  1. I have created a user , using time stamp example :  test20121112131234 (testyyyymmddhhmmss)
  2. Verify text present test20121112131234
  3. driver.findElement(By.id("search_text")).sendKeys("____paste the text that was verified_____");

Please help...

Iakiv Kramarenko

unread,
Aug 16, 2013, 2:15:50 AM8/16/13
to webd...@googlegroups.com
Hi, Pushpraj,

Did you find the solution for your problem? Can you share?

Thanks,
Yakiv

Понеділок, 12 листопада 2012 р. 09:47:14 UTC+2 користувач Pushpraj Singh написав:
Reply all
Reply to author
Forward
0 new messages