Google chrome 防止在新选项卡中打开指定的url
我正在使用SeleniumWeb驱动程序,想测试一个chrome扩展。我通过在本地添加chrome扩展的路径加载了chrome扩展,它运行良好。但它也给了我在新标签中打开指定url的副作用。如果我删除了负责chrome扩展的in代码,那么它就可以正常工作[指定打开,而不是在新选项卡中打开] 我使用下面的代码Google chrome 防止在新选项卡中打开指定的url,google-chrome,google-chrome-extension,selenium-webdriver,Google Chrome,Google Chrome Extension,Selenium Webdriver,我正在使用SeleniumWeb驱动程序,想测试一个chrome扩展。我通过在本地添加chrome扩展的路径加载了chrome扩展,它运行良好。但它也给了我在新标签中打开指定url的副作用。如果我删除了负责chrome扩展的in代码,那么它就可以正常工作[指定打开,而不是在新选项卡中打开] 我使用下面的代码 DesiredCapabilities capabilities = DesiredCapabilities.chrome(); ChromeOptions
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);
远程url是“127.0.0.1:9515”,这是本地url,然后我通过
driver.get("www.google.com");
它在新标签中重定向我,我真的不想要。如果我删除
options.addArguments("--load-extension=E:\\ExtensionChrome\\Moment\\MomentForYouTube","--start-maximized");
这条线对我来说很好。欢迎任何帮助。这与硒无关。这一切都与你的分机有关。我们将无法帮助您,除非您自己开发了扩展,并将其代码发布在这里。