1

enter image description here

Below mentioned code is working fine, the problem i'm facing is that when I enter CAPTCHA and click proceed button, the website doesn't recognize the selection for NetBanking Tab, the said selection is done through the below mentioned VBA code only.

I have to select it manually and then only it is proceeding further.

The error is marked with Red Arrow in the attached image.

What should be the possible correction ?

Sub TDS_Autofill()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://onlineservices.tin.egov-nsdl.com/etaxnew/tdsnontds.jsp"
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

Set doc = IE.document
doc.parentWindow.execScript "sendRequest(281)", "JavaScript"

Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop


If ThisWorkbook.Sheets("Challan AutoFill").Range("n2").Value = "Company" Then
doc.getElementById("0020").Click
ElseIf ThisWorkbook.Sheets("Challan AutoFill").Range("n2").Value = "Non Company" Then
doc.getElementById("0021").Click
End If



If ThisWorkbook.Sheets("Challan AutoFill").Range("p2").Value = "(200) TDS/TCS Payable by Taxpayer" Then
doc.getElementById("200").Click
ElseIf ThisWorkbook.Sheets("Challan AutoFill").Range("p2").Value = "(400) TDS/TCS Regular Assessment" Then
doc.getElementById("400").Click
End If


IE.document.querySelector("select.form-control").selectedIndex = ThisWorkbook.Sheets("Challan AutoFill").Range("s2").Value



doc.getElementById("NetBanking").Click

doc.getElementById("NetBank_Name_c").Value = ThisWorkbook.Sheets("Challan AutoFill").Range("u2").Value


doc.getElementsByName("TAN")(1).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("b2").Value

IE.document.querySelector("select[name=AssessYear]").selectedIndex = ThisWorkbook.Sheets("Challan AutoFill").Range("m2").Value


doc.getElementsByName("Add_Line1")(1).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("c2").Value

doc.getElementsByName("Add_Line2")(1).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("d2").Value

doc.getElementsByName("Add_Line3")(1).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("e2").Value

doc.getElementsByName("Add_Line4")(1).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("f2").Value

doc.getElementsByName("Add_Line5")(1).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("g2").Value


IE.document.querySelector("select[name=Add_State]").selectedIndex = 21


doc.getElementsByName("Add_PIN")(1).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("i2").Value

doc.getElementsByName("Add_EMAIL")(0).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("j2").Value

doc.getElementsByName("Add_MOBILE")(0).Value = ThisWorkbook.Sheets("Challan AutoFill").Range("K2").Value

End Sub
8
  • The indicated dropdown is not available given your prior selection. What exactly are you trying to achieve? Please indicate the exact selections required before submit. Commented Oct 14, 2019 at 18:29
  • Is there are .value property to getElementById("NetBanking").? Commented Oct 14, 2019 at 18:30
  • All the selections are automatically done by my code, but the website is not treating the selection for NetBanking Tab as a selection, I have given the value of Axis Bank for NetBanking Tab and it is also getting selected through the code, but website is treating it as a blank as if nothing is selected there. Commented Oct 14, 2019 at 18:41
  • getElementById("NetBanking") is just a button, there are no .value property to it. Commented Oct 14, 2019 at 18:43
  • Hmmm... perhaps I am missing something. However, that bottom dropdown cannot be selected from if you have checked the radio button next to the dropdown directly above. Does that make sense? Commented Oct 14, 2019 at 19:01

1 Answer 1

1

Fire the onchange events associated with each dropdown (select). Also, use faster css selectors throughout and you can improve your page load wait conditions. Replace type + attribute selectors with faster id + class. Use querySelector so as to work with a single element over gathering collections and indexing.

Option Explicit
Public Sub TDS_Autofill()
    Dim IE As Object

    Set IE = CreateObject("InternetExplorer.Application")
    With IE
        .Visible = True
        .Navigate2 "https://onlineservices.tin.egov-nsdl.com/etaxnew/tdsnontds.jsp"

        While .Busy Or .readyState <> 4: DoEvents: Wend

        .document.parentWindow.execScript "sendRequest(281)"

        While .Busy Or .readyState <> 4: DoEvents: Wend

        With .document
            .querySelector("#\30 021").Click
            .querySelector("#\32 00").Click
            .querySelector("[value='94C - Payment of contractors and sub-contractors']").Selected = True
            .querySelector("#div_nature_error .form-control").FireEvent "onchange"
            .querySelector("[value='Axis Bank|https://www.axisbiconnect.co.in/tax/tax.asp']").Selected = True
            .querySelector("#NetBank_Name_c").FireEvent "onchange"
            .querySelector("#div_nature_error .form-control").selectedIndex = 2
            .querySelector(".input-pan").Value = "BPLU00890B"

            With .querySelector("#div_assessment_error .form-control")
                .selectedIndex = 3
                .FireEvent "onchange"
            End With

            .querySelector("#div_add_line1_error .form-control").Value = "83/18"
            .querySelector("#div_add_line2_error .form-control").Value = "Advance College"
            .querySelector("#div_add_line4_error .form-control").Value = "Vishnu Pura"
            .querySelector("#div_add_line5_error .form-control").Value = "Ujjain"

            With .querySelector("#div_state_error .form-control")
                .selectedIndex = 21
                .FireEvent "onchange"
            End With

            .querySelector("#div_pincode_error .form-control").Value = "your_pin"
            .querySelector("#div_email_error .form-control").Value = "[email protected]"
            .querySelector("#div_mobile_error .form-control").Value = "your_mobile"

            Stop                                 'Enter captcha

            .querySelector("#Submit").Click
            Stop '<== delete me later
        End With
        .Quit
    End With
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.