根据我之前的问题,我将 Opera 降级到 V40,从昨天开始我遇到了按钮点击和切换到 iframe 等问题。
所以我将 Opera 升级到 v44 并从这里下载了适用于 windows 64 的 Operadriver v2.27 的最新版本。
初始化驱动:
static string path = @"C:\Drivers";
public static IWebDriver _driverInstance = null;
_driverInstance = new OperaDriver(path);
最初我有一个例外
Result Message: Initialization method HomePage_Tests.Init threw exception. System.InvalidOperationException: System.InvalidOperationException: unknown error: cannot find Opera binary
(Driver info: OperaDriver=2.27 (f61056e560d197467fd6d27c7fbd7fea572fe8bd),platform=Windows NT 10.0.14393 x86_64).
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.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Opera.OperaDriver..ctor(String operaDriverDirectory, OperaOptions options)
at OpenQA.Selenium.Opera.OperaDriver..ctor(String operaDriverDirectory)
at SmartDebitTestFramework.Drivers.Initialize(String browser)
然后将代码更改为
DesiredCapabilities capabilities = DesiredCapabilities.Opera();
OperaOptions options = new OperaOptions();
options.BinaryLocation = path;
capabilities.SetCapability(OperaOptions.Capability, options);
_driverInstance = new OperaDriver(options);
现在例外是:
Result Message: Initialization method HomePage_Tests.Init threw exception. System.InvalidOperationException: System.InvalidOperationException: unknown error: Opera failed to start
(Driver info: OperaDriver=2.27 (f61056e560d197467fd6d27c7fbd7fea572fe8bd),platform=Windows NT 10.0.14393 x86_64).
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.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Opera.OperaDriver..ctor(OperaDriverService service, OperaOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Opera.OperaDriver..ctor(OperaOptions options)
at SmartDebitTestFramework.Drivers.Initialize(String browser)
您能否帮助正确设置以使 Opera 正常工作。
谢谢。