Automatically click yes button in ATF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12m ago
Hi Buddy,
ATF can’t reliably “see” buttons inside a custom modal with the normal Click component step, so the usual way to automate this is to click it with a client-side script.
In your ATF test, add a step like Run Client Script and click the Yes button from the DOM, for example:
// click the visible "Yes" button in the open modal
var yesBtn = Array.from(document.querySelectorAll('button, a, input'))
.find(el => ((el.innerText || el.value || '').trim().toLowerCase() === 'yes') &&
(el.offsetWidth || el.offsetHeight || el.getClientRects().length));
if (yesBtn) yesBtn.click();That will close the confirmation automatically with no manual involvement.
If you can change the UI, the best long-term fix is to add something stable like an id or data-testid to the Yes button (ex: data-testid="confirm-yes"), then ATF can click it directly without guesswork.
@SasidharBat - Please mark Accepted Solution and Thumbs Up if you found Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8m ago
I could see it's a modal.
Did you try to use Click Component (Custom UI) step?
You need to retrieve the HTML elements and then only you can tell ATF what to click.
where are you stuck?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
