1

根据我之前的问题,我将 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 正常工作。

谢谢。

4

2 回答 2

1

我已经以这种方式解决了这个问题:

//Opera settings OperaDriverService service = OperaDriverService.CreateDefaultService(@""); \\path to OD OperaOptions options = new OperaOptions(); options.BinaryLocation = @""; \\path to my Opera browser WebDriver = new OperaDriver(service, options);

于 2017-09-15T10:13:50.653 回答
0

你能像这样试试吗

capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.BrowserName, "operablink");
capabilities.setCapability("opera.binary", "/path/to/your/opera");
capabilities.Platform = new Platform(PlatformType.Windows);
_webDriver = new OperaDriver(capabilities);

在您的节点上:

{
  "capabilities":
  [
    {
      "browserName": "operablink",
      "platform": "WINDOWS",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 1,
  "port": 5555,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://localhost:4444",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}
于 2017-05-03T11:24:00.537 回答