--- /dev/null
+<?php
+
+namespace Drupal\DrupalExtension\Context;
+
+use Behat\MinkExtension\Context\RawMinkContext;
+
+/**
+ * Extensions to the Mink Extension.
+ */
+class BatchContext extends RawMinkContext {
+
+ /**
+ * Wait for the Batch API to finish.
+ *
+ * Wait until the id="updateprogress" element is gone,
+ * or timeout after 3 minutes (180,000 ms).
+ *
+ * @Given /^I wait for the batch job to finish$/
+ */
+ public function iWaitForTheBatchJobToFinish() {
+ $this->getSession()->wait(180000, 'jQuery("#updateprogress").length === 0');
+ }
+
+}