Automate Data Entry with Chrome Using Excel Macros
How to automate data entry with Chrome using Excel macros and Selenium. Details available at www.exceltrain...
Here's the complete VBA macro code:
Option Explicit
Dim driver As New WebDriver
Sub Test()
Dim keys As New SeleniumWrapper.keys
driver.Start "chrome"
driver.Get "\"
driver.Window.Maximize
driver.Wait 1000
driver.FindElementById("State").Click
driver.FindElementById("State").SendKeys Sheet1.Cells(2, 1).Value
driver.Wait 1000
driver.FindElementById("District").Click
driver.FindElementById("District").SendKeys Sheet1.Cells(2, 2).Value
driver.Wait 1000
driver.SendKeys (keys.Enter)
driver.FindElementByName("RespondentAge").SendKeys Sheet1.Cells(2, 3).Value
driver.Wait 1000
driver.FindElementByName("RespondentName").SendKeys Sheet1.Cells(2, 4).Value
driver.Wait 1000
driver.FindElementByName("RespondentMobileNo").SendKeys Sheet1.Cells(2, 5).Value
driver.Wait 1000
driver.FindElementByName("RespondentGender").Click
driver.Wait 1000
driver.FindElementByName("RespondentGender").SendKeys Sheet1.Cells(2, 6).Value
driver.Wait 1000
driver.FindElementByClass("btn-primary").Click
'driver.SendKeys (keys.Enter)
driver.FindElementByName("FQ1").Click
driver.FindElementByName("FQ1").SendKeys Sheet1.Cells(2, 7).Value
driver.Wait 1000
driver.FindElementByName("FQ2").Click
driver.FindElementByName("FQ2").SendKeys Sheet1.Cells(2, 8).Value
driver.Wait 1000
driver.FindElementByName("FQ3").Click
driver.FindElementByName("FQ3").SendKeys Sheet1.Cells(2, 9).Value
driver.Wait 1000
driver.FindElementByName("FQ4").Click
driver.FindElementByName("FQ4").SendKeys Sheet1.Cells(2, 10).Value
driver.Wait 1000
driver.FindElementByName("FQ5").Click
driver.FindElementByName("FQ5").SendKeys Sheet1.Cells(2, 11).Value
driver.Wait 1000
driver.SendKeys (keys.Enter)
End Sub
Пікірлер: 44