Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Selenium WebDrive-Chrome意外警报打开_C#_Selenium - Fatal编程技术网

C# Selenium WebDrive-Chrome意外警报打开

C# Selenium WebDrive-Chrome意外警报打开,c#,selenium,C#,Selenium,我偶尔会收到一个警报窗口,它对我正在测试的内容没有影响,但是它会抛出异常,应用程序停止爬行 如何使chrome停止和弹出消息一起 using (var driver = new ChromeDriver(@"C:\hrtr")) unexpected alert open (Session info: chrome=36.0.1985.125) (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1

我偶尔会收到一个警报窗口,它对我正在测试的内容没有影响,但是它会抛出异常,应用程序停止爬行

如何使chrome停止和弹出消息一起

using (var driver = new  ChromeDriver(@"C:\hrtr"))

          unexpected alert open
  (Session info: chrome=36.0.1985.125)
 (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)     

通过使用特定选项,您可以让驱动程序忽略任何意外警报

你可以尝试下面的代码,这是IE。你可以采用它的铬

var options = new InternetExplorerOptions();
    options.UnexpectedAlertBehavior = OpenQA.Selenium.IE.InternetExplorerUnexpectedAlertBehavior.Ignore;

driver = new InternetExplorerDriver(options);

你不知道测试中的应用程序什么时候会抛出警报吗?ChromeDriver没有一个等价的选项,这真的很不幸,因为我收到间歇性警报,ChromeDriver退出太快,无法确定警报是什么。InternetExplorerDriverOptions类:ChromeDriverOptions类:ChromeDriverOptions类:有一些适合Chrome的东西你确定吗?我提供了一个到源代码的链接,但在其中没有看到任何提供此功能的内容。如果它在那里(并命名为完全不同的东西),你能看一看,让我们确切地知道什么属性提供相同的功能吗?是的,我肯定。但我现在无法为你做到这一点。