Exit course
Chapter 10 of 10 Intermediate 6 min read Updated

Selenium C# Quiz

Ten questions on the decisions this course made and why. Each answer explains the reasoning once you check. The quiz is a self-check; nothing is recorded.

1. A new project has Selenium.WebDriver, NUnit and the Selenium.WebDriver.ChromeDriver package. What should you change before the first commit?

Selenium Manager inside Selenium.WebDriver resolves the right driver at run time, so a pinned driver package only causes version mismatches. Without the adapter and test SDK, dotnet test discovers no tests at all. MSTest needs its own adapter too.

2. The build fails with NUnit1032, "The field driver should be Disposed in a method annotated with [TearDownAttribute]", although TearDown calls driver.Quit(). What is the cleanest fix?

Quit() closes the browser and disposes the driver; the analyzer just does not know that. The setting teaches it once. Removing the analyzers loses checks that catch real bugs, and calling both works but adds noise to every teardown.

3. Which wait returns the element only once it can be typed into?

Until keeps polling while the lambda returns null, so returning the element only when it is displayed and enabled waits for exactly that. Option b only waits for presence; option c does not compile in Selenium 4, which has no ExpectedConditions.

4. A test passes when run headed and fails headless with ElementClickInterceptedException on a button near the bottom of the page. What do you check first?

"Click intercepted" means the element was found but something else is on top of it at that point. A smaller viewport changes the layout; giving headless Chrome a desktop window size fixed exactly this in chapter 3. A wrong locator would give a different error.

5. You want one login test to run for a list of accounts built at run time from a CSV file, each account reported separately. What do you use?

[TestCase] takes only constants, and hand-copying data means it drifts from the file. A loop produces one result and stops at the first failure. [TestCaseSource] turns each row into its own named test.

6. Inside using (Assert.EnterMultipleScope()), the second of five assertions calls FindElement on an element that does not exist. What does the report show?

The scope collects assertion failures, but an unexpected exception still ends the test immediately, reported together with any failures recorded before it. Make sure the page is ready before the block and use the block for details.

7. A page object keeps private IWebElement submit, found in its constructor. What is the risk?

An element reference points at one DOM node. Keeping a By locator and finding the element when an action runs always gets the current node.

8. A grid test fails in NUnit, but the TestingBot dashboard shows it with no result. Which TearDown order is correct?

The tb: command travels over the open WebDriver session, so it must run before Quit(). The grid has no access to NUnit's results. After quitting, only the REST API can still set the status.

9. With [assembly: Parallelizable(ParallelScope.All)], tests in the same class fail at random with ObjectDisposedException. What does the course add?

By default all tests in a fixture share one instance, so parallel tests overwrite and quit each other's driver. One instance per test removes the sharing. A static driver makes it worse, and locks would serialise the tests again.

10. A pull request puts the TestingBot key and secret in a committed .runsettings file "so CI works". What should you ask for instead?

Anything committed, in any file or encoding, is readable by everyone with repository access and stays in history. Environment variables from CI secrets keep credentials out of the code, and a pair that was committed should be replaced.

Where to go next#

You finished Selenium C# Tutorial with NUnit

Put what you learned into practice. Run your tests on 6100+ real browsers and physical iOS and Android devices.