In some cases, the application triggers the popup which seems to be intermittent. During browser click path record, we may the record the click event to close the popup. However this popup appear intermittent and we may get the intermittent errors.
Go to the relevant page on Chrome browser
Right click on the element which you want to interact with on the popup page-> Inspect the element which will open the developer tools
if(document.querySelectorAll('button[class="btn cancel"]').length>0) // For example on this page, element tag is button and attribute is class="btn cancel" . You can modify this based on your application page.