shayster01
shayster01

Reputation: 214

Applescript Webforms

I am trying to make an applescript that submit a form on mxtoolbox.com that uses AJAX at this link:

http://mxtoolbox.com/EmailHeaders.aspx

tell application "Safari"
    activate
    tell (make new document) to set URL to "http://mxtoolbox.com/EmailHeaders.aspx"
    delay 10
    tell application "System Events"
-- Copies text from variable headerText to clipboard and paste. Faster than keystroke headerText
        set the clipboard to headerText
        keystroke "v" using command down

    end tell
end tell

Any ideas?

A suggestion was the following but it still did not work:

tell application "Safari"
    activate
    tell (make new document) to set URL to "http://mxtoolbox.com/EmailHeaders.aspx"
    delay 10
    tell application "System Events"
        set the clipboard to headerText
        keystroke "v" using command down
        tell application "Safari"
            do JavaScript ("
document.getElementById('ctl00_ContentPlaceHolder1_txtToolInput').value='" & headerText as text) & "';
document.getElementById('ctl00_ContentPlaceHolder1_btnAction').click();
" in document 1
        end tell
    end tell
end tell

Upvotes: 0

Views: 132

Answers (1)

user309603
user309603

Reputation: 1538

You could do this with JavaScript:

set headerText to "test"

tell application "Safari"
    activate
    tell (make new document) to set URL to "http://mxtoolbox.com/EmailHeaders.aspx"
    delay 5

    do JavaScript "
    document.getElementById('ctl00_ContentPlaceHolder1_txtToolInput').value=" & quoted form of headerText & ";
    document.getElementById('ctl00_ContentPlaceHolder1_btnAction').click()" in document 1
end tell

Upvotes: 1

Related Questions