c# - Webdriver 浏览器日志记录 IE C#

标签 c# selenium internet-explorer selenium-webdriver webdriver

所以我尝试使用 selenium webdriver (2.53.1) 创建一个脚本,该脚本可以检测和记录显示混合内容的站点。我快速环顾四周,发现

Driver.Manage().Logs.GetLog(LogType.Browser);

但是你必须用下面的设置你的驱动程序

ChromeOptions options = new ChromeOptions();
options.SetLoggingPreference(LogType.Browser, LogLevel.All);
driver = new ChromeDriver(options);

上面的代码适用于 chrome,但是当我为我的 IEDriver 尝试类似的设置时

InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
ieOptions.EnsureCleanSession = true;
ieOptions.RequireWindowFocus = true;
ieOptions.IgnoreZoomLevel = true;
Driver = new InternetExplorerDriver(ieOptions);

我得到以下异常

Test Name:  Test
Test FullName:  sniper_regression.ExistingUser("ie").Test
Test Source:    c:\git\sniper-regression\sniper-regression\ExistingUser.cs : line 559
Test Outcome:   Failed
Test Duration:  0:00:32.02

Result Message: 
System.InvalidOperationException : Command not found: POST /session/51ed52d9-5842-4fe6-b854-e40edad1654f/log
Command duration or timeout: 0 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'CHI-GRID-NODE1', ip: '10.34.161.112', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=false, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=true, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=true, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=true, browserName=internet explorer, initialBrowserUrl=http://localhost:43728/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 51ed52d9-5842-4fe6-b854-e40edad1654f
Result StackTrace:  
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteLogs.GetLog(String logKind)
   at sniper_regression.ExistingUser.Test() in c:\git\sniper-regression\sniper-regression\ExistingUser.cs:line 559

GetLog() 是否需要针对 IE 进行不同的设置?任何建议将不胜感激,谢谢。

最佳答案

IE 驱动程序现在不支持,也从来没有支持任何日志记录 API。这部分是因为 IE 驱动程序的(无偿,志愿者)开发人员和 WebDriver 的创建者都认为 API 的远程端设计不佳,并且 API 将来可能会发生变化。此外,Internet Explorer 浏览器本身不会以编程方式公开成功实现当前设计的 WebDriver 日志记录 API 所需的所有功能。但是,IE 驱动程序在 GitHub 上可用,并且接受实现新功能的拉取请求。

关于c# - Webdriver 浏览器日志记录 IE C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41558380/

相关文章:

internet-explorer - IE8的开发者工具兼容模式下的IE7对于测试网站前端设计是否可靠?

c# - ASP.NET 中的自制 MessageBox.Show()

c# - 具有单独程序集和加载控件的 MEF WPF 应用程序

c# - 什么可能导致此内存问题?

java - 选择包含特定 linkText 的元素之前的元素

javascript - htmlCollection child 不在 IE 中工作

c# - 使用 .NET 代码防止进程产生

java - 如何通过文本来识别元素?

java - 如何使用java在selenium中输入日历中的特定日期(链接)

跨浏览器的 CSS 问题,但 IE 工作?