Skip to content

Commit da15bf7

Browse files
Docs: Improving clickWithLeftButton()
Page: https://codeception.com/docs/modules/WebDriver#clickWithLeftButton
1 parent af40aff commit da15bf7

1 file changed

Lines changed: 10 additions & 22 deletions

File tree

src/Codeception/Module/WebDriver.php

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,7 +2952,7 @@ public function dragAndDrop($source, $target): void
29522952
* then the mouse is moved to an offset of the element's top-left corner.
29532953
* Otherwise, the mouse is moved to the center of the element.
29542954
*
2955-
* ``` php
2955+
* ```php
29562956
* <?php
29572957
* $I->moveMouseOver(['css' => '.checkout']);
29582958
* $I->moveMouseOver(null, 20, 50);
@@ -2974,21 +2974,21 @@ public function moveMouseOver($cssOrXPath = null, ?int $offsetX = null, ?int $of
29742974
}
29752975

29762976
/**
2977-
* Performs click with the left mouse button on an element.
2978-
* If the first parameter `null` then the offset is relative to the actual mouse position.
2979-
* If the second and third parameters are given,
2980-
* then the mouse is moved to an offset of the element's top-left corner.
2981-
* Otherwise, the mouse is moved to the center of the element.
2977+
* Performs a click with the left mouse button.
2978+
* If the first parameter is given, then the offset is measured from the center of that element.
2979+
* If the first parameter is `null`, then the offset is relative to the actual mouse position.
2980+
* To debug, you can use `clickWithRightButton()` and see where the context menu is located.
29822981
*
2983-
* ``` php
2982+
* ```php
29842983
* <?php
29852984
* $I->clickWithLeftButton(['css' => '.checkout']);
29862985
* $I->clickWithLeftButton(null, 20, 50);
29872986
* $I->clickWithLeftButton(['css' => '.checkout'], 20, 50);
29882987
* ```
29892988
*
2990-
* @param null|string|array|WebDriverBy $cssOrXPath css or xpath of the web element (body by default).
2991-
*
2989+
* @param null|string|array|WebDriverBy $cssOrXPath css or xpath of the web element (default: `<body>`).
2990+
* @param ?int $offsetX Positive number moves to the right
2991+
* @param ?int $offsetY Positive number moves downwards
29922992
* @throws ElementNotFound
29932993
*/
29942994
public function clickWithLeftButton($cssOrXPath = null, ?int $offsetX = null, ?int $offsetY = null): void
@@ -2998,18 +2998,7 @@ public function clickWithLeftButton($cssOrXPath = null, ?int $offsetX = null, ?i
29982998
}
29992999

30003000
/**
3001-
* Performs contextual click with the right mouse button on an element.
3002-
* If the first parameter `null` then the offset is relative to the actual mouse position.
3003-
* If the second and third parameters are given,
3004-
* then the mouse is moved to an offset of the element's top-left corner.
3005-
* Otherwise, the mouse is moved to the center of the element.
3006-
*
3007-
* ``` php
3008-
* <?php
3009-
* $I->clickWithRightButton(['css' => '.checkout']);
3010-
* $I->clickWithRightButton(null, 20, 50);
3011-
* $I->clickWithRightButton(['css' => '.checkout'], 20, 50);
3012-
* ```
3001+
* See <a href="#clickWithLeftButton">clickWithLeftButton()</a>
30133002
*
30143003
* @param null|string|array|WebDriverBy $cssOrXPath css or xpath of the web element (body by default).
30153004
* @throws ElementNotFound
@@ -3020,7 +3009,6 @@ public function clickWithRightButton($cssOrXPath = null, ?int $offsetX = null, ?
30203009
$this->webDriver->getMouse()->contextClick();
30213010
}
30223011

3023-
30243012
/**
30253013
* Performs a double click on an element matched by CSS or XPath.
30263014
*

0 commit comments

Comments
 (0)