delex
delex

Reputation: 211

Selenium disable Restore pages poup

i am using selenium C#, i am trying to disable the pop up of "crashed" chrome: https://i.sstatic.net/xudon.png

i tried to set the profile preferences, but its seems that the it ain't changing at all, the code:

        ChromeOptions options = new ChromeOptions();
        options.AddUserProfilePreference("exit_type", "Normal");
        options.AddUserProfilePreference("exited_cleanly", "true");
        IWebDriver driver = new ChromeDriver(options);

i tried to change the value of exit type to none & None, but without any change at the preferences document.

Upvotes: 7

Views: 6573

Answers (6)

Mystic
Mystic

Reputation: 141

After a month of searching, I found a solution. The --disable-session-crashed-bubble parameter, which is written about everywhere, is not relevant. Use --hide-crash-restore-bubble. Tested with python + selenium, works.

Example:

...
    def _options(self):
        chrome_options = Options()
        chrome_options.add_argument('--hide-crash-restore-bubble')
        # some other options
        return chrome_options
...

Upvotes: 6

kamda cyrial
kamda cyrial

Reputation: 101

I tested the Answer given by @Icy, and it worked for me. what I used was :

prefs = {'exit_type': 'Normal'}
option.add_experimental_option("prefs", {'profile': prefs})

and it is spoken of by https://superuser.com/a/1343331, only issue is with the method listed there, you will need to edit the file manually every time, so this works way better, tested in may 2021. Just couldn't upvote the answer as I have no reputation yet, and it is the last.

Upvotes: 2

Icy
Icy

Reputation: 1

Try this code:

prefs = {'exit_type': 'Normal'}

chrome_options.add_experimental_option("prefs", {'profile': prefs})

Upvotes: -1

Rustam Shafigullin
Rustam Shafigullin

Reputation: 376

I'm using C# and I've noticed that chrome driver can be closed propery only when we use Close() method followed by Quit() in finally block. No special options required. I think in java it's the same way. This will help to rid of "Restore pages" while launching chrome with the driver

ChromeOptions options = new ChromeOptions();
options.AddArgument(Configure.chromeProfileDir);
options.AddArgument(Configure.chromePath);

ChromeDriver d = null;

try
{
    d = new ChromeDriver(options);
    d.Navigate().GoToUrl("https://google.com");

    // Your operations...
}
catch(Exception e)
{
    // Handle your exceptions...
}
finally 
{
    try 
    {
        d.Close();
        d.Quit();
    } 
    catch(Exception e) 
    {
    }
}

Upvotes: 3

sgaga
sgaga

Reputation: 1

i tried this code in java, it solved my problem :))

    ChromeOptions options = new ChromeOptions();
    options.addArguments("user-data-dir="+profilepath);     
    options.addArguments("--no-startup-window");
    // argument "--no-startup-window" make chrome is failed to start -> selenium will quit chrome normaly 
    //-> start chrome again, it won't show restore page
    try {
        driver = new ChromeDriver(options); 
    }catch(Exception ex){                           
    }
    options = new ChromeOptions();
    options.addArguments("user-data-dir="+profilepath);
    driver = new ChromeDriver(options);

Upvotes: 0

Raj
Raj

Reputation: 674

Use below code to handle this pop up:

ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-extensions");
options.AddArguments("--disable-application-cache");
driver = new ChromeDriver(options);

Upvotes: 0

Related Questions