Search and Select the asset for Uploads

I am using the below code for automation of searching for a file and then select the file for Uploads

In the search box of the application i am searching for file Applescriptautomation and it will return one file results. But i am unable to select the file. Key board actions doesnot select the file.

tell application “Aspera Connect”
activate
tell application “System Events”
tell process “IBM Aspera Connect”

		set value of text field 1 of window 1 to "Applescriptautomation.jpg"
		selectfile 'Applescriptautomation.jpg' 
	end tell
end tell

end tell

I can’t test but maybe this edited version has more chance to work.

tell application "Aspera Connect"
    activate
    tell application "System Events"
        tell process "IBM Aspera Connect"
            
            set value of text field 1 of window 1 to "Applescriptautomation.jpg"
			-- selectfile 'Applescriptautomation.jpg' -- what you wrote
            select file "Applescriptautomation.jpg" -- EDITED
        end tell
    end tell
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 16 mars 2020 09:58:42

I have not this application installed. But I don’t believe it is scriptable and has command select. Therefore, I think your workaround is turned upside down. It would be more correct to first select the file itself, and then send its path to the text field 1 of the window:


set aFilePath to POSIX path of (choose file)

tell application "Aspera Connect" to activate
tell application "System Events" to tell process "IBM Aspera Connect"
	repeat while text field 1 of window 1 exists -- wait for text field 1
		delay 0.1
	end repeat
	tell text field 1 of window 1 to keystroke aFilePath & return -- upload
end tell