4

Does Selenium WebDriver support multithreading well?

I'm trying to use it with several windows opened 2-4, and it looks like browser window (Firefox) gets freezed sometimes.

When one thread starts:

_driver.FindElement(By.Id(id)).SendKeys("MyMessage");

And another thread at the same time tries to get another page element state.

How to deal wit this?

Are there any recomendations on accessing the same page from different threads?

How to speed up the SendKeys method, and not allow selenium to access the page while SendKeys still not finished?

1 Answer 1

3

In my experience, Selenium WebDriver supports multithreading quite well (unless you're using IE). From your code, it looks like you are using the same driver instance in all of your threads - make sure each thread has its own WebDriver instance.

Sign up to request clarification or add additional context in comments.

6 Comments

If that doesn't help, please say why instead of simply down-voting. it's a learning process for all of us.
For what it's worth, I'm working with the same problem. I've tried using separate WebDriver instances (and/or threadstatic fields) to make this work. So far that approach has resulted in AccessViolations (IE) and Selenium exceptions (FF) stemming from problems with multiple threads either a) accessing the same implicit WebDriver server, or b) trying to spin up multiple WebDriver servers. I think the successful approach will need to instantiate a shared server instance & point every thread's driver instance at that, but I haven't worked it out yet.
Interesting - it's been a while since I've run a multi-threaded WebDriver scenario, things must have changed (which explains the downvote). Thanks for your input, I'll do some digging and see if I can get it working again.
I'm posting a related question as well; I've changed some stuff & I think ThreadLocal<FirefoxWebDriver> is mostly doing the job now, but there's some weirdness with dead FF instances that's knocking me for a (parallel) loop. ;)
I've been wanting to implement heartbeat functionality for webdriver to take care of dead browser sessions, perhaps now is the time...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.