drew
drew

Reputation: 25

clicking a button in javascript without button id or class

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?

Upvotes: 0

Views: 530

Answers (1)

Nathan
Nathan

Reputation: 499

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

Upvotes: 3

Related Questions