Unable to input any data in input field in selenium

40 views Asked by At

Below is the element details of input field

<input name="aadharNumber" placeholder="Enter Aadhaar No." error="[object Object]" maxlength="12" type="text" class="form-control" value="">

I have written following code

bot.FindElementByClass("form-control").SendKeys ("242730110592")

I have also tried using

bot.FindElementByname("aadharNumber").SendKeys ("242730110592")

Please help me in entering data in input field

1

There are 1 answers

0
MT1 On

This code works for me. Note the SendKeys method can use parentheses or without.

Option Explicit
Sub sbTest()
    Dim bchr As Selenium.ChromeDriver
    Set bchr = New Selenium.ChromeDriver
    Dim Keys As New Selenium.Keys
    Dim sURL As String
    Dim sUsername As String
    Dim sPassword As String
    sUsername = "myusername"
    sPassword = "mypassword"
    Call bchr.Start("chrome")
    bchr.Get ("https://www.wordpress.com")
    sbDelay (100000)
    bchr.Window.Maximize
    sbDelay (100000)
    bchr.SendKeys (Keys.Tab)
    bchr.SendKeys (Keys.Tab)
    bchr.SendKeys (Keys.Tab)
    bchr.SendKeys (Keys.Tab)
    bchr.SendKeys (Keys.Tab)
    bchr.SendKeys (Keys.Tab)
    bchr.SendKeys (Keys.Enter)
    sbDelay (100000)
    bchr.SendKeys sUsername
    bchr.SendKeys (Keys.Enter)
    sbDelay (100000)
    bchr.SendKeys sPassword
    bchr.SendKeys (Keys.Enter)
    sbDelay (100000)
    sbDelay (100000)
    sbDelay (100000)
    bchr.Quit
End Sub
Sub sbDelay(delay As Long): Dim i As Long: For i = 1 To delay: DoEvents: Next i: End Sub