Mac OS Save and replace file

I am trying to save a web page(download) in mac using XTYPE ${KEY_CMD+KEY_S}. (for save) and then type the file name and press enter(after pause) using XTYPE ${KEY_ENTER}. This works the first time when the file name is unique.

But, I would like to save the file everytime with the same name and not say append date time to the name of the file to make it unique. Thus when the file saves on ‘ENTER’ it presents a ‘file already exists with Do you want to replace ?’ dialog with a cancel and replace button.
So far so good,
However I am unable to click the replace option to get past it and begin the download.
When I try to pass XTYPE ${KEY_CMD+KEY_R} (R for replace) through UI vision it just cancels the download. (This cmd+R combination works in a real manual operation to trigger replace button on this dialog)

Can some one help please ?

switch to desktop mode and click replace button and then switch off desktop mode

Excellent. Thanks, @uiuser .
I was able to switch to desktop mode and use XClick to send a click to the ‘replace’ button.