Is it possible somehow to reuse already opened browser while operating in selenium webdriver?
Q: Is it possible somehow to reuse already opened browser while operating in selenium webdriver?
As far as I know selenium webdriver has no inbuilt feature that would allow to maintain/reuse already opened browser. Every time to see the code changes you have to run a test from scratch in a new browser session and it is kind of torment to wait till the actual test is executed
I use TestNG/java while creating tests. My level of automation is novice. I would appreciate if you could highlight this topic in one of your chapters dedicated to selenium webdriver
It would be nice if you could provide step-by-step instructions (code) how to implement this for those who have basic knowledge of all required technologies: Java, TestNG and etc.
Thank you in advance!
Basically if you want to use the same driver through the session dont call driver.quit or close on it. Also make sure that the same driver object that you create is passed around to different tests. It is a broad question that you have asked and it has many possible solutions.
I would suggest that you create a browser factory which delivers you browsers on demand. In the factory make sure that you maintain the same instance of the browser.
I think I had posted the code earlier once. Let me see and come back to this again, However you can take a look at Factory Design pattern here