Selenium VBA code to paste data in browser

时间:2015-06-30 13:59:24

标签: vba excel-vba selenium selenium-webdriver selenium-chromedriver

I am trying to stimulate the control+v option in a text box in chrome using selenium vba wrapper. I tried using the context click but that function seems to click at a random position based on the cursor position. I tried using the send key function but i am not getting the desired result.

selenium.SendKeys (key.Control & "v")

Please any advise or leads would be much appreciated.

2 个答案:

答案 0 :(得分:0)

我认为您最好使用变量来保存数据而不是剪贴板。然后,您可以使用sendkeys在其中键入:

myData= "your data here"
selenium.sendkeys myData

HTH

答案 1 :(得分:0)

您希望在使用sendkeys之前定位文本框。假设,假设有一个名为textbox1的ID用于识别元素:

driver.FindElementById("textbox1").SendKeys("yourString")

或者

driver.FindElementById("textbox1").SendKeys Keys.Control, "v"

后者假设信息已经在剪贴板中,例如driver.SetClipBoard "yourString"