Your script would have to query whether there is a popup alerting to the incomplete document, and handle that situation accordingly.
Sounds like your script already handles the "happy path" when the document is complete. Add logic to check whether the incompletion popup appeared - you have a 'control exists' condition for this in scripting. If there is a popup, you could click on the 'Save' button.
Don't forget a 'Refresh Screen' before using the IF control exists condition.