Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to instantiate variable like WebDriverWait when test are given driver type as test case?
    primarykey
    data
    text
    <p>I am doing UI tests. At first I started with Firefox Browser driver only so I would declare the WebDriverWait variable under the class and would assign it under the [SetUp] method as shown in the code block and every test would be able to use it.</p> <pre><code>public class FirefoxTest { public IWebDriver _driver; public WebDriverWait _wait; [SetUp] public void SetupTest() { _driver = new FirefoxDriver(); _wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(30)); } </code></pre> <p>Then I tried to incorporate more BrowserDrivers by specifying them with the [TestCaseSource(typeof(WebDriverFactory), "Drivers")] attribute. So now the _driver variable have to be moved out of the [SetUp] and _wait variable doesn't know what _driver to use.</p> <p>I tried to instantiate it in every Test but that was repetitive and those test used methods that also require WebDriverWait variable and those methods would not run a second time when another test tries to implement them because the WebDriverWait variable would already be declared.</p> <p>My question is where can I instantiate WebDriverWait and other things that are driver dependent and that are usually written in [SetUp] and [TearDown] such as driver.Quit() when the driver are given as [TestCase].</p> <p>Right now I have test written like</p> <pre><code>[TestCaseSource(typeof(WebDriverFactory), "Drivers")] public void SomeTest(IWebDriver driver){ driver.Navigate().GoTo.... } </code></pre> <p>The problem is that I then have to include </p> <pre><code>WebDriverWait _wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); driver.Quit() </code></pre> <p>in all the tests and the _wait in all the methods that are reused in the tests. Things that I had in the [SetUp] and [Teardown].</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload