Try using System Events:
tell application "System Events" to tell process "Safari"
click button "OK" of window 1
end tell
tell application "System Events" to tell process "Safari"
set value of text field 1 of window 1 to "aa"
click button "OK" of window 1
end tell