0

How to handle Gmail popup? See screenshot.

enter image description here

Roy Scheffers
  • 3,832
  • 11
  • 31
  • 36
aditya sharma
  • 19
  • 1
  • 4
  • Hi Aditya, welcome to Stack Overflow. Can you elaborate on your question as currently, it is unclear what you want to achieve? What is the current behavior and what would you like it to be. Thanks – Roy Scheffers Aug 23 '18 at 06:15
  • Click "Leave" ... – Teemu Aug 23 '18 at 06:16
  • I have create a script for send mail and after that logout, but after running send mail script its showing popup. There is no way to find element for that popup. only this popup buttons work that time. – aditya sharma Aug 23 '18 at 06:33
  • Please explain exactly what you want to achieve, as the other comment requested. – CertainPerformance Aug 23 '18 at 06:47
  • See after sending mail i want logout and that script working fine, but some times this popup appeared, I just want to handle this popup. – aditya sharma Aug 23 '18 at 06:59
  • I can't test it thoroughly, but I'd recommend trying a userscript that runs on `document-start` that makes `window.onbeforeunload` unwritable, and intercepts and discards `addEventListener` calls that try to attach to `beforeunload`. – CertainPerformance Aug 23 '18 at 07:11
  • Maybe try to turn off Javascript. This should help – kleusmeus Aug 23 '18 at 06:16

1 Answers1

0

You may handle it by try-catch,

Sample Example:

You can call this method where you required, Else you can directly implement try-catch code where it throws.

public boolean isAlertPresent() {
    try {
        driver.switchTo().alert().accept();
        return true;
    } catch (Exception Ex) {
        return false;
    }
}
Ishita Shah
  • 3,955
  • 2
  • 27
  • 51