防止在新选项卡中打开指定的URL

时间:2014-04-21 10:43:11

标签: google-chrome google-chrome-extension selenium-webdriver

我正在使用selenium web-driver并想测试一个chrome扩展。我通过在我的本地添加chrome扩展路径来加载chrome扩展,它工作正常。但它给了我在新标签中打开指定网址的副作用。如果我删除了负责chrome扩展的in代码,那么它工作正常[打开指定不在新标签中打开]。

我正在使用以下代码。

        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--load-extension=E:\\ExtensionChrome\\Moment\\MomentForYouTube","--start-maximized");
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        driver = new RemoteWebDriver(new URL(REMOTEWEBDRIVER_URL), capabilities);

远程网址是“127.0.0.1:9515”,这是本地网址,然后我通过

抓取指定的网址
driver.get("www.google.com");

它在新标签中重定向我,我真的不想要。如果我删除

options.addArguments("--load-extension=E:\\ExtensionChrome\\Moment\\MomentForYouTube","--start-maximized");

这条线然后它对我来说很好。任何帮助都是适当的。

0 个答案:

没有答案