Run multiple instances of Selenium driver in same machine

大城市里の小女人 提交于 2020-01-04 05:47:04

问题


I am automating a Web app in Chrome using Selenium in C#. I have created separate code bases (exe copies) which would trigger the automation independent of each other, to make this automation faster. Each of the exes launches Chrome and triggers the automation but sometimes I get a Windows pop-up message displaying- 'ChromeDriver.exe has stopped working'. This should not happen as I already have the chromedriver.exe kept under separate code bases which is being triggered by each instances. Also, I am disposing the chromedriver properly for each instance. If I run a single instance it works fine.

Please let me know if I could provide more details or some code snippets that you would like to check.

Thanks, Souvik


回答1:


if you wish to run multiple automations at the same time, use threading with multiple instances of IWebDriver

EX:

public void Work()
{
IWebDriver driver = new ChromeDriver("D:\\Drivers");
driver.Navigate().GoToUrl(URL);
\\Do the rest
}
public void Work2()
{
IWebDriver driver = new ChromeDriver("D:\\Drivers");
driver.Navigate().GoToUrl(URL2);
\\Do the rest
}

and call the function like this:

Thread thread1 = new Thread(new ThreadStart(Work));
thread1.Start();
Thread thread2 = new Thread(new ThreadStart(Work2));
thread2.Start();


来源:https://stackoverflow.com/questions/41182807/run-multiple-instances-of-selenium-driver-in-same-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!