diff --git a/src/Browser.php b/src/Browser.php index 5a4b2d09a..7471226a2 100644 --- a/src/Browser.php +++ b/src/Browser.php @@ -466,7 +466,7 @@ public function screenshotElement($selector, $name) } $this->scrollIntoView($selector) - ->driver->findElement(WebDriverBy::cssSelector($selector)) + ->driver->findElement(WebDriverBy::cssSelector($this->resolver->format($selector))) ->takeElementScreenshot($filePath); return $this; diff --git a/tests/Unit/BrowserTest.php b/tests/Unit/BrowserTest.php index bf47f422c..7d2d58907 100644 --- a/tests/Unit/BrowserTest.php +++ b/tests/Unit/BrowserTest.php @@ -244,7 +244,7 @@ public function test_screenshot_in_subdirectory() $this->assertFileExists(Browser::$storeScreenshotsAt.'/'.$name.'.png'); } - public function test_element_screenshot() + public function test_screenshot_element() { $elementMock = $this->createMock(RemoteWebElement::class); $elementMock->expects($this->once()) @@ -256,7 +256,7 @@ public function test_element_screenshot() $driverMock = $this->createMock(RemoteWebDriver::class); $driverMock->expects($this->once()) ->method('findElement') - ->with(WebDriverBy::cssSelector('#selector')) + ->with(WebDriverBy::cssSelector('body #selector')) ->willReturn($elementMock); $browser = new Browser($driverMock); @@ -271,7 +271,7 @@ public function test_element_screenshot() $this->assertFileExists(Browser::$storeScreenshotsAt.'/'.$name.'.png'); } - public function test_element_screenshot_in_subdirectory() + public function test_screenshot_element_in_subdirectory() { $elementMock = $this->createMock(RemoteWebElement::class); $elementMock->expects($this->once()) @@ -283,7 +283,7 @@ public function test_element_screenshot_in_subdirectory() $driverMock = $this->createMock(RemoteWebDriver::class); $driverMock->expects($this->once()) ->method('findElement') - ->with(WebDriverBy::cssSelector('#selector')) + ->with(WebDriverBy::cssSelector('body #selector')) ->willReturn($elementMock); $browser = new Browser($driverMock);