1

I just got back into selenium testing and I'm using the basics:

initialized on top is

public static WebDriver driver=null;

and then depending on what is set in a properties file, it loads either the chromedriver or edgedriver.

System.setProperty("webdriver.edge.driver", System.getProperty("user.dir")+"//BrowserDrivers//msedgedriver.exe");

driver = new EdgeDriver();

and for chrome:

System.out.println(System.getProperty("user.dir")+"//BrowserDrivers//chromedriver.exe");

driver = new ChromeDriver();

it works for the most part, except it keeps opening two browser pages at once? which eventually leads to a disconnect because it uses the second page opened, then when it tries to close the page (ie, driver.quit()) to start the next test case, it successfully closes the page it ran the first test but because of the first page that was opened, it throws this error:

WARNING: Process refused to die after 10 seconds, and couldn't taskkill it
java.lang.RuntimeException: Couldn't detect pid

I am using the most updated and stable versions of both webdrivers and selenium4.5, and webdrivermanager5.3

droidnoob
  • 333
  • 5
  • 17
  • each time you call new ChromeDriver() or new EdgeDriver() you're going to have a driver and browser launch. If you want to multi-thread those two, you need two driver references. So driver1 = new EdgeDriver(), driver2 = new ChromeDriver();... then pass those references into each threaded class. – pcalkins Oct 06 '22 at 17:09
  • @pcalkins I don't want to multithread, that's the issue. I edited the question to explain a bit further. But in my case, I only want one at a time and depending on what the user selects, it should open either one chrome browser or one edge browser. However, it opens two chrome browsers or two edge browsers – droidnoob Oct 06 '22 at 17:23
  • You should include more of the code. Something's causing new ChromeDriver() to be called twice. Also is there some reason you're initializing to null? – pcalkins Oct 06 '22 at 18:34

0 Answers0