Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

java - How to use a already opened firefox for testing in Selenium

This declaration

WebDriver driver = new FirefoxDriver();

always opens a new instance window of Firefox. It doesn't use the already opened firefox.

Can anyone let me know how to use a already opened firefox for testing instead of opening a new one?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use Remote Web Driver like this .

System.Uri uri = new System.Uri("http://localhost:7055/hub");
WebDriver = new RemoteWebDriver(uri, DesiredCapabilities.Firefox());

it will use the already opened Firefox browser. you can see the details of this approach in this blog post.

http://www.binaryclips.com/2016/03/selenium-web-driver-in-c-how-to.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...