当我使用selenium grid 2时,我无法在浏览器之间切换 相同的代码与网格工作正常。
详情如下。 我在selenium网格中使用RemotewebDriver IE浏览器正在启动而且我是 能够登录我的应用程序登录后打开另一个窗口,现在我 我无法切换到新窗口。
但是当我使用InternetExplorerDriver而不使用selenium grid 2(RemotewebDriver)时,相同的代码正常工作。请帮帮我。
示例代码
使用远程webdriver
WebDriver driver;
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,
org.openqa.selenium.UnexpectedAlertBehaviour.IGNORE);
capabilities.setBrowserName("internet explorer");
capabilities.setPlatform(Platform.WIN8);
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setJavascriptEnabled(true);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
没有使用远程webdriver
WebDriver driver;
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,
org.openqa.selenium.UnexpectedAlertBehaviour.IGNORE);
capabilities.setBrowserName("internet explorer");
capabilities.setPlatform(Platform.WIN8);
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setJavascriptEnabled(true);
String baseDIRPath = System.getProperty("user.dir");
String IEDriverServerpath = baseDIRPath+ "\\utilities\\IEDriverServer.exe";
File file = new File(IEDriverServerpath);
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver(capabilities);
谢谢, SYAM