I'm trying to code an autoclicker in a Chrome extension using Javascript, however with a special type a button.
Here are 2 examples of the button:
<button ng-bind-html="option.value" type="button" tabindex="15" ng-click="optionClickHandler(option)" ng-disabled="formFieldModel.disabled || isOptionDisabled(option) || showSpinner" ng- >The App</button>
and
<button ng-bind-html="option.value" type="button" tabindex="15" ng-click="optionClickHandler(option)" ng-disabled="formFieldModel.disabled || isOptionDisabled(option) || showSpinner" ng- >NTC App</button>
How can I click one of them when both are displayed on the page? Thank you.
CodePudding user response:
If you use jQuery
$('button:contains("The App")').click()
Otherwise
Array.from(document.querySelectorAll('button'))
.filter(s => s.innerText === "The App")
.forEach(s => s.click())
CodePudding user response:
As far as I can tell the only difference between the buttons is the class. You can select a button with the specific class like this:
$("button.ng-binding")