Fala Glayson, tudo bem?
Em vez de instanciar as implementações reais, como o FirefoxDriver, você precisa instanciar um RemoteWebDriver. Ao instanciar o RemoteWebDriver, você pode usar o objeto DesiredCapabilities para determinar qual máquina (e, portanto, qual usuário) o Selenium escolherá para executar o navegador. Por exemplo:
public IWebDriver CreateNewBrowserFor(string Who)
{
//Decide which of Selenium nodes we want to connect to
string CapabilitiesOfTargetUser;
if(Who.Equals("user1"))
{
//We need to control a browser for user1 on his node
CapabilitiesOfTargetUser = "platform=Mac;browserName=firefox";
}
else if(Who.Equals("me"))
{
//We need to control a browser for me on my node
CapabilitiesOfTargetUser = "platform=WINDOWS";
}
else
{
throw new ArgumentException();
}
//Create a Selenium DesiredCapabilities object that contains our choosen capabilities
Dictionary<string, object> RequestedCapabilities = new Dictionary<string, object> ();
string[] CapabilitiesArray = CapabilitiesOfTargetUser.Split(';');
foreach(string KeyValuePair in CapabilitiesArray)
{
string key = KeyValuePair.Split('=').First().Trim();
string value = KeyValuePair.Split('=').Last().Trim();
RequestedCapabilities[key] = value;
}
DesiredCapabilities Capabilities = new DesiredCapabilities(RequestedCapabilities);
//Create the RemoteWebDriver. Selenium's hub will ensure that this RemoteWebDriver is
//actually controlling a new browser on the correct machine
return new RemoteWebDriver
(
new Uri("http://localhost:4444/wd/hub")
, Capabilities
, new TimeSpan(0, 0, 50)
);
}