1

I'm attempting to check a checkbox on a website.

Checkbox HTML:

<input name="ApplicationSearchGroupsSelect_0" title='Select "Basic Access - Computer Logon"' type="checkbox" value="1">

HTML Above Checkbox:

<form name="main" id="main" onkeypress="return imOnKeyPress(event)" action="?facesViewId=/app/page/screen/standard_search.jsp" method="post">

Code:

Set objinputs = aExplorer.document.getElementsByTagName("form")
For Each ele In objinputs
    If ele.Name Like "ApplicationSearchGroupsSelect_0" And ele.Title Like "Select "Basic Access - Computer Logon"" Then
        ele.Focus
        ele.Click
        ele.Selected = True
        ele.Checked = True
        ele.FireEvent "onkeypress"
        End If
    Next

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

    aExplorer.document.getElementById("main").FireEvent ("onkeypress")
    Do While aExplorer.Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop

Nothing happens when I try to run this code (no error message, code completes running and nothing is checked). Beyond firing the javascript event, trying to click the button, check the checkbox, make selected=true, I don't know how to click this checkbox and hours of scouring the web hasn't returned anything. I've also tried changing the value to 0,1,2 and nothing occurs.

Any ideas on how to check a checkbox outside of what I've tried? Thanks!

2
  • I don't think that And ele.Title Like "Select "Basic Access - Computer Logon"" would even compile. Double quotes within a string need to be escaped by putting two double quotes in a row, like this: And ele.Title Like "Select ""Basic Access - Computer Logon""" Then Commented Feb 9, 2017 at 0:25
  • Set objinputs = aExplorer.document.getElementsByTagName("input") Commented Feb 9, 2017 at 6:45

1 Answer 1

1

Try

aExplorer.document.forms("main").getElementsByName ("name=""ApplicationSearchGroupsSelect_0""")(0)

Or,

aExplorer.document.getElementsByTagName("form")(0).getElementsByName ("name=""ApplicationSearchGroupsSelect_0""")(0)
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.