1
votes

I am trying to get the apple script to click on the radio button. I am very new to this. I am getting this error: error "Google Chrome got an error: Can’t make theScript of active tab of tab id 1.521810707E+9 of window id 1.52181061E+9 into type specifier." number -1700 from theScript of active tab of tab id 1.521810707E+9 of window id 1.52181061E+9 to specifier

The code:

to clickID(theID)

tell application "Google Chrome"
    tell window 1 to tell (make new tab)
        set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
        delay 5
        set theScript to "document.getElementById('" & theID & "')'.click();"
        execute javascript theScript in active tab
    end tell
end tell

end clickID clickID("optFormatCSV")

Here is a screenshot of the button and copy from inspecting the element:

The Screenshot

InspectElement

InspectElement

Pls help :(

1

1 Answers

0
votes

A couple of errors with your script:

tell application "Google Chrome"
    tell window 1 to tell (make new tab)
        set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
        delay 5
        set theScript to "document.getElementById('" & theID & "')'.click();"
        execute javascript theScript in active tab
    end tell
end tell

You've got a stray quote before ".click()", which makes the JavaScript invalid; and you are targeting the active tab inside a tell (make new tab) block. It's the latter that is producing your error:

Can’t make theScript of active tab of tab id ... of window id ...

There's no such object as active tab belonging to the tab id ... (the tab you just created) of window 1.

Simply remove the reference to the active tab and your code should work. Here's what your corrected handler should look like:

tell application "Google Chrome"
    tell window 1 to tell (make new tab)
        set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
        delay 5
        set theScript to "document.getElementById('" & theID & "').click();"
        execute javascript theScript
    end tell
end tell

System info: AppleScript version: 2.7 System version: 10.13.6 Chrome version: 69