Selenium: Getting chrome didn't shut down correctly

后端 未结 3 982
南笙
南笙 2021-01-20 05:44

I\'m getting the chrome didn\'t shut down correctly error message when I reopen a chrome browser in my selenium framework.

In the framework I\'m opening the browser

3条回答
  •  無奈伤痛
    2021-01-20 05:50

    Did you set exit_type:Normal, I'm currently doing that before the test start, and or after the test ends and it Works. on C#

     public static void FixChromeSingleProfile(string dataDir)
        {
            FileStream fs = new FileStream(dataDir, FileMode.OpenOrCreate);
            StreamReader sr = new StreamReader(fs);
            string json = sr.ReadToEnd();
            sr.Close();
            fs.Close();
            dynamic jsonDe = JsonConvert.DeserializeObject(json);
            if (jsonDe.profile.exit_type != "Normal")
            {
                jsonDe.profile.exit_type = "Normal";
                string r = JsonConvert.SerializeObject(jsonDe);
    
                StreamWriter sw = new StreamWriter(dataDir, false);
                sw.Write(r);
                sw.Close();
            }
        }
    

提交回复
热议问题