在selenium中是否有可能为已经打开的FF浏览器创建实例?

时间:2016-11-03 06:57:31

标签: selenium selenium-webdriver

我的申请中遇到以下挑战。

一旦应用程序启动,它将使用C:\ Program Files \ Mozilla Firefox \ firefox.exe自动打开FF浏览器

现在我想使用selenium为打开的FF窗口创建一个实例,然后继续。

WebDriver webDriver = null; 
try { 
   URL uri = new URL("localhost:7055/hub"); 
   webDriver = new RemoteWebDriver(uri, DesiredCapabilities.firefox()); 
   System.out.println("Executed on remote driver"); 
} catch (Exception e) { 
   webDriver = new FirefoxDriver(); 
   System.out.println("Executed on New FireFox driver"); 
}

1 个答案:

答案 0 :(得分:0)

Allow webdriver to attach to a running browser中所述:

I'm going to make a call on this one: it's a browser specific feature, and not something
that we can implement in a general way. With IE, it's possible to iterate over the
open windows in the OS and find the right IE process to attach to.

Firefox and Chrome, OTOH, need to be started in a specific mode and configuration,
which means that just attaching to a running instance isn't technically possible.

Closing as "not feasible" here as this is a browser specific feature.

无法将selenium附加到已打开的firefox浏览器实例。