public function setUp() { $this->testCase = $this->getMockBuilder(AbstractTestCase::class)->setMethods(['getName'])->getMock(); $this->testCase->expects($this->any())->method('getName')->willReturn('testFooMethod'); ConfigHelper::setEnvironmentVariables(ConfigHelper::getDummyConfig()); ConfigHelper::unsetConfigInstance(); }
/** * Subroutine to encapsulate creation of real WebDriver. Handles some exceptions that may occur etc. * The WebDriver instance is stored to $test->wd when created. * * @param AbstractTestCase $test * @param $remoteServerUrl * @param \DesiredCapabilities $capabilities * @param $connectTimeoutMs * @param $requestTimeoutMs */ protected function createWebDriver(AbstractTestCase $test, $remoteServerUrl, \DesiredCapabilities $capabilities, $connectTimeoutMs, $requestTimeoutMs) { $browserName = ConfigProvider::getInstance()->browserName; for ($startAttempts = 0; $startAttempts < 4; $startAttempts++) { try { $test->wd = RemoteWebDriver::create($remoteServerUrl, $capabilities, $connectTimeoutMs, $requestTimeoutMs); return; } catch (\UnknownServerException $e) { if ($browserName == 'firefox' && strpos($e->getMessage(), 'Unable to bind to locking port') !== false) { // As a consequence of Selenium issue #5172 (cannot change locking port), Firefox may on CI server // collide with other FF instance. As a workaround, we try to start it again after a short delay. $test->warn('Firefox locking port is occupied; beginning attempt #%d to start it ("%s")', $startAttempts + 2, $e->getMessage()); sleep(1); continue; } elseif (strpos($e->getMessage(), 'Error forwarding the new session') !== false) { $test->warn("Cannot execute test on the node. Maybe you started just the hub and not the node?"); } throw $e; } } $test->warn('All %d attempts to instantiate Firefox WebDriver failed', $startAttempts + 1); throw $e; }