Copy Paste with Webdriver not working for MAC OS

1,835 views
Skip to first unread message

Pavithra

unread,
May 14, 2013, 1:34:20 AM5/14/13
to webd...@googlegroups.com
I am trying to achieve copy, paste via webdriver.
I tried using below code in Windows OS:

To copy:
element.click();
element.sendkeys(Keys.CONTROL + "a");
element.sendkeys(Keys.CONTROL + "c");

To paste:
element.click();
element.sendkeys(Keys.CONTROL + "v");

It works charm!!

However in MAC when I tried the below:
To copy:
element.click();
element.sendkeys(Keys.COMMAND + "a");
element.sendkeys(Keys.COMMAND + "c");

To paste:
element.click();
element.sendkeys(Keys.COMMAND + "v");

Both copy, paste doesnt work in MAC. It does nothing.

I tried using via action builder class, also using keychord, but doesnt help.
Can anyone suggest to make it work on MAC ?

Thanks,
Pavithra

Krishnan Mahadevan

unread,
May 14, 2013, 2:54:30 AM5/14/13
to webdriver
I think native events dont work on MAC. Have you tried setting the value directly via javascript instead on MAC ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


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

darrell

unread,
May 14, 2013, 2:52:54 PM5/14/13
to webdriver
What are you trying to copy and paste? Rather than getting into
operating system specific actions, you might want to see if you can do
the same thing with Selenium or javascript commands. For example, if
you are trying to get the text inside a web element, get the
WebElement than save the element.getText(). Same thing as a copy. The
paste then does a sendKeys with the string from the element.getText().
This is Java but the same idea should work with other bindings, The
syntax will be slightly different.

If you are trying to copy the value from an <INPUT> element then you
want to use element.getAttribute("value"); rather than getText().

Goscha Graf

unread,
May 4, 2015, 8:04:06 PM5/4/15
to webd...@googlegroups.com
So this will never work on OS X? What about when you are trying to select all text with CMD+A and then clicking a button in the UI to make it bold?
Reply all
Reply to author
Forward
0 new messages