0

I'm trying to use AppleScript to click a button on a webpage, however the button I need to click doesn't have an ID or Class, and it's located inside a div/input tag:

<div style="margin:0;padding:0;position:absolute;width:100px;right:20px"><input style="padding:4px;height:2em;width:100px" type="submit" value="save" tabindex="-1"></div>
<input style="padding:4px;height:2em;width:100px" type="submit" value="save" tabindex="-1">

I tried using querySelector, but it didn't work. How do I go about clicking this button?

drew
  • 25
  • 6
  • You've tagged this [javascript] but you're talking about AppleScript. As far as I know they are different languages. – Heretic Monkey May 23 '20 at 21:23
  • Does this answer your question? [Find an element in DOM based on an attribute value](https://stackoverflow.com/questions/2694640/find-an-element-in-dom-based-on-an-attribute-value) – Heretic Monkey May 23 '20 at 21:27
  • Heretic Monkey they are different languages, but in AppleScript there is a "do Javascript" command, which allows you to use Javascript to interact with web pages. I used it successfully to input text into a search bar. I should have included the [AppleScript] tag as well though, the problem was with AppleScript – drew May 23 '20 at 22:11

1 Answers1

3

In this case an attribute selector would work fine, I'd imagine.

document.querySelector('input[value="save"]')

More information from MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

Nathan
  • 479
  • 6
  • 13
  • Thank you so much! I was able to use your example, coupled with a helpful article I found elsewhere, and the solution was: do JavaScript " document.querySelector(\"input[value='save']\").click();" Thank you for your help! – drew May 23 '20 at 22:12