无法通过 Selenium WebDriver 自动化 Opera 浏览器
Not able to automate Opera browser through Selenium WebDriver
我正在自动化一个 Web 应用程序,该应用程序 运行 在 3 种浏览器中运行,即 IE、Mozilla 和 Chrome。
现在,当我尝试在具有不同功能的 Opera 中 运行 相同的代码时,它会打开 Opera 浏览器,但在 URL 中只有数据;显示并且我的测试不是 运行ning.
这是我的示例代码:
DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();
System.setProperty("webdriver.opera.driver", "C:\Important\Test\web\src\test\resources\operadriver.exe");
driver = new OperaDriver(capabilities);
driver.manage().window().maximize();
我收到以下错误:
org.openqa.selenium.WebDriverException: Opera not reachable (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
请尝试
DesiredCapabilities capabilities = DesiredCapabilities.opera();
我用 Windows 10、Selenium 3.5.2、Opera 52.0 和 OperaDriver 2.35 试过了,下面的代码对我有用。
DesiredCapabilities capablities=DesiredCapabilities.opera();
System.setProperty("webdriver.opera.driver", "C:\automation\opera\operadriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\Program Files\Opera\launcher.exe");
capablities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
OperaDriver driver = new OperaDriver(capablities);
driver.get("https://www.google.com");
driver.findElement(By.name("q")).sendKeys("how to use opera with selenium");
我正在自动化一个 Web 应用程序,该应用程序 运行 在 3 种浏览器中运行,即 IE、Mozilla 和 Chrome。
现在,当我尝试在具有不同功能的 Opera 中 运行 相同的代码时,它会打开 Opera 浏览器,但在 URL 中只有数据;显示并且我的测试不是 运行ning.
这是我的示例代码:
DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();
System.setProperty("webdriver.opera.driver", "C:\Important\Test\web\src\test\resources\operadriver.exe");
driver = new OperaDriver(capabilities);
driver.manage().window().maximize();
我收到以下错误:
org.openqa.selenium.WebDriverException: Opera not reachable (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
请尝试
DesiredCapabilities capabilities = DesiredCapabilities.opera();
我用 Windows 10、Selenium 3.5.2、Opera 52.0 和 OperaDriver 2.35 试过了,下面的代码对我有用。
DesiredCapabilities capablities=DesiredCapabilities.opera();
System.setProperty("webdriver.opera.driver", "C:\automation\opera\operadriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\Program Files\Opera\launcher.exe");
capablities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
OperaDriver driver = new OperaDriver(capablities);
driver.get("https://www.google.com");
driver.findElement(By.name("q")).sendKeys("how to use opera with selenium");