Hi scripting experts! I’m at a roadblock with the new tool I’m scripting and I’d love to consult the experts here
--Insert by element ID
to inputByID(theId, theValue)
--Insert by element Class
to inputByClass(theclass, num, theValue)
I’m doing searches on a webform and need to run one search criteria each time. Rather than do one search, refresh, another; I would open multiple tabs and do one criteria search on each tab. This is where AppleScript will come in handy!
By using one of the handlers above I’ve managed to tell Safari to open multiple tabs and pre-fill the information I need at the correct fields.
Safari isn’t registering that the fields have content filled in it and keeps the “Search” button greyed out. Usually when you key in something, even a space, the Search button would be enabled and you can click on it. It appears that when texts are pre-filled with AppleScript, Safari is thinking that there is nothing in the fields.
NOTE: Unfortunately the webform I’m working on is a private site that cannot be shared publicly.
but adjusted for the actual form name in the relevant site.
If that doesn’t work - it’s a less robust and elegant solution, but as long as the page in questions stays relatively static, it is likely you could use UI scripting to control the keyboard to tab through the form and type in the information.
It’s hard for us to provide specific help without access to the page in question.
Again, this would need adapting to your specific page.
That’s precisely it! But when I looked up how to simulate a mouse click with AppleScript, it looks like you’ll need to give it coordinates, which is not really desirable as my browser is never at the same location lol
Rather than simulating clicks, I think t.spoon’s suggestion of controlling the keyboard to tab through the form is going to be the solution. I’ve tentatively overcome this by having System Event tab the correct times and Keystroke the input and return
Not elegant or robust but… gets the job done lol :lol:
I got this to work with the following script, but the only thing is that all it does is refresh the page lol (I’m not entirely sure if I found the right name to replace “exampleform” but that’s the only replacement that did something so I assume it was correct)
This is my current solution :lol: I solved the roadblock by opening a new tab, tab the correct times and keystroke the input and then return. As you said, not as elegant and robust but hey, gets the job done!