public static Browser GetBrowser(BrowserTypes browserType) { lock (ThisLock) { var threadId = Thread.CurrentThread.ManagedThreadId; var testContext = TestContext.CurrentContext.Test.FullName; var browser = browserType == BrowserTypes.FromConfig ? BrowserHelper.EvaluateType(Config.BrowserType) : browserType; if (BrowserCollection.ContainsKey(threadId)) { if (BrowserCollection[threadId].BrowserType == browser) { ThisLog.Debug($"{testContext}: Browser '{browser}' for thread '{threadId}' existed in the BrowserCollection. Reused."); return(BrowserCollection[threadId]); } } BrowserCollection.Add(threadId, GetNewBrowser(browser)); ThisLog.Debug($"{testContext}: Browser '{browser}' for thread '{threadId}' added into BrowserCollection."); return(BrowserCollection[threadId]); } }
public TestSetUp(string browserType) { BrowserType = BrowserHelper.EvaluateType(browserType); }