Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Codeception/Constraint/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function matches($nodes): bool
* @param string|array|WebDriverBy $selector
* @param ComparisonFailure|null $comparisonFailure
*/
protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never
protected function fail($nodes, $selector, ?ComparisonFailure $comparisonFailure = null): never
{
if (count($nodes) === 0) {
throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath');
Expand Down Expand Up @@ -89,7 +89,7 @@ protected function failureDescription($nodes): string
* @param string|null $contains
* @return string
*/
protected function nodesList(array $nodes, string $contains = null): string
protected function nodesList(array $nodes, ?string $contains = null): string
{
$output = "";
foreach ($nodes as $node) {
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Constraint/WebDriverNot.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function matches($nodes): bool
* @param string|array|WebDriverBy $selector
* @param ComparisonFailure|null $comparisonFailure
*/
protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never
protected function fail($nodes, $selector, ?ComparisonFailure $comparisonFailure = null): never
{
if (!is_string($selector) || strpos($selector, "'") === false) {
$selector = Locator::humanReadableString($selector);
Expand Down
26 changes: 13 additions & 13 deletions src/Codeception/Module/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ public function _failed(TestInterface $test, $fail)
/**
* Print out latest Selenium Logs in debug mode
*/
public function debugWebDriverLogs(TestInterface $test = null): void
public function debugWebDriverLogs(?TestInterface $test = null): void
{
if ($this->webDriver === null) {
$this->debug('WebDriver::debugWebDriverLogs method has been called when webDriver is not set');
Expand Down Expand Up @@ -901,7 +901,7 @@ public function _savePageSource(string $filename): void
* // saved to: tests/_output/debug/2017-05-26_14-24-11_4b3403665fea6.png
* ```
*/
public function makeScreenshot(string $name = null): void
public function makeScreenshot(?string $name = null): void
{
if (empty($name)) {
$name = uniqid(date("Y-m-d_H-i-s_"));
Expand Down Expand Up @@ -931,7 +931,7 @@ public function makeScreenshot(string $name = null): void
*
* @param WebDriverBy|array $selector
*/
public function makeElementScreenshot($selector, string $name = null): void
public function makeElementScreenshot($selector, ?string $name = null): void
{
if (empty($name)) {
$name = uniqid(date("Y-m-d_H-i-s_"));
Expand All @@ -947,7 +947,7 @@ public function makeElementScreenshot($selector, string $name = null): void
$this->debugSection('Screenshot Saved', "file://{$screenName}");
}

public function makeHtmlSnapshot(string $name = null): void
public function makeHtmlSnapshot(?string $name = null): void
{
if (empty($name)) {
$name = uniqid(date("Y-m-d_H-i-s_"));
Expand Down Expand Up @@ -1325,7 +1325,7 @@ protected function findField($selector): WebDriverElement
return reset($arr);
}

public function seeLink(string $text, string $url = null): void
public function seeLink(string $text, ?string $url = null): void
{
$this->enableImplicitWait();
$nodes = $this->getBaseElement()->findElements(WebDriverBy::partialLinkText($text));
Expand Down Expand Up @@ -2765,7 +2765,7 @@ public function executeInSelenium(Closure $function)
* });
* ```
*/
public function switchToWindow(string $name = null): void
public function switchToWindow(?string $name = null): void
{
$this->webDriver->switchTo()->window($name);
}
Expand All @@ -2792,7 +2792,7 @@ public function switchToWindow(string $name = null): void
*
* @param string|null $locator (name, CSS or XPath)
*/
public function switchToIFrame(string $locator = null): void
public function switchToIFrame(?string $locator = null): void
{
$this->findAndSwitchToFrame($locator, 'iframe');
}
Expand All @@ -2819,12 +2819,12 @@ public function switchToIFrame(string $locator = null): void
*
* @param string|null $locator (name, CSS or XPath)
*/
public function switchToFrame(string $locator = null): void
public function switchToFrame(?string $locator = null): void
{
$this->findAndSwitchToFrame($locator);
}

private function findAndSwitchToFrame(string $locator = null, string $tag = 'frame'): void
private function findAndSwitchToFrame(?string $locator = null, string $tag = 'frame'): void
{
if ($locator === null) {
$this->webDriver->switchTo()->defaultContent();
Expand Down Expand Up @@ -2962,7 +2962,7 @@ public function dragAndDrop($source, $target): void
* @param null|string|array|WebDriverBy $cssOrXPath css or xpath of the web element
* @throws ElementNotFound
*/
public function moveMouseOver($cssOrXPath = null, int $offsetX = null, int $offsetY = null): void
public function moveMouseOver($cssOrXPath = null, ?int $offsetX = null, ?int $offsetY = null): void
{
$where = null;
if (null !== $cssOrXPath) {
Expand Down Expand Up @@ -2991,7 +2991,7 @@ public function moveMouseOver($cssOrXPath = null, int $offsetX = null, int $offs
*
* @throws ElementNotFound
*/
public function clickWithLeftButton($cssOrXPath = null, int $offsetX = null, int $offsetY = null): void
public function clickWithLeftButton($cssOrXPath = null, ?int $offsetX = null, ?int $offsetY = null): void
{
$this->moveMouseOver($cssOrXPath, $offsetX, $offsetY);
$this->webDriver->getMouse()->click();
Expand All @@ -3014,7 +3014,7 @@ public function clickWithLeftButton($cssOrXPath = null, int $offsetX = null, int
* @param null|string|array|WebDriverBy $cssOrXPath css or xpath of the web element (body by default).
* @throws ElementNotFound
*/
public function clickWithRightButton($cssOrXPath = null, int $offsetX = null, int $offsetY = null): void
public function clickWithRightButton($cssOrXPath = null, ?int $offsetX = null, ?int $offsetY = null): void
{
$this->moveMouseOver($cssOrXPath, $offsetX, $offsetY);
$this->webDriver->getMouse()->contextClick();
Expand Down Expand Up @@ -3487,7 +3487,7 @@ protected function isPhantom(): bool
*
* @param string|array|WebDriverBy $selector
*/
public function scrollTo($selector, int $offsetX = null, int $offsetY = null): void
public function scrollTo($selector, ?int $offsetX = null, ?int $offsetY = null): void
{
$el = $this->matchFirstOrFail($this->getBaseElement(), $selector);
$x = $el->getLocation()->getX() + $offsetX;
Expand Down