0

I have a scenario where I am trying to copy a range of cells (Single Column) from Excel and paste the range in a textarea tag in Chrome browser, which is identified using ID. I am using Excel VBA and Selenium.

There seems to be no error when copying of the range. However, when I try to paste the range in the textarea using Selenium Keys, I am currently unable to paste the values. As my Excel range can sometimes extend to more than 1000 rows, I am out of option to paste the cells one after the other, as the browser times out.

My html code is something like this.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

<div>
    <div>
        <textarea> id = "textarea1"
        </textarea>
    </div>
</div>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

I have tried using the below three codes, in vain.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

selenium.findElementByID("textarea1").sendkeys (keys.Control & "v")
selenium.findElementByID("textarea1").sendkeys keys.Control, "v"
selenium.findElementByID("textarea1").sendkeys (keys.Control +"v")

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Can someone help me identify the issue here and the workaround.

Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

0

I'm not sure what keybindings you're using for Selenium (Python or Java?).

Anyway, you want to send a key chord. Please look at the examples in Key press in (Ctrl+A) Selenium WebDriver.

So maybe you want:

selenium.findElementByID("textarea1").sendKeys(Keys.chord(Keys.CONTROL,"v"))
Eliah Kagan
  • 1,704
  • 3
  • 22
  • 38
swagrov
  • 1,510
  • 3
  • 22
  • 38
  • I am not sure of the keybindings you are talking about. Hope this helps. This is how I am calling the key bindings. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dim keys As New SeleniumWrapper.keys =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= – Sathish Kumar Dec 05 '17 at 17:37
  • Okay I see you are using the VBA keybindings. I misunderstood your background info. Please look at https://stackoverflow.com/questions/35449770/selenium-vba-to-control-chrome and see that they use `driver.SendKeys Keys.Control, "t"` – swagrov Dec 05 '17 at 18:05