Skip to content

Commit 4f4f347

Browse files
committed
Merge branch '0.x' into 'master'
2 parents 06b6f31 + 732edb5 commit 4f4f347

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99
### Changed
1010

11-
- No changes yet.
11+
- No description yet.
12+
13+
## [0.2.1] - 2020-12-22
14+
### Fixed
15+
16+
- `WebDriverInterface::waitUntil()`: a resulting value from the promise, that has been generated by the
17+
"condition-to-satisfy" callback, is now properly forwarded to the `onFulfilled` handler, for the `waitUntil` method
18+
itself.
1219

1320
## [0.2.0] - 2020-12-18
1421
### Added
@@ -77,6 +84,7 @@ browser instance).
7784
This early development version doesn't yet contain full implementation for the introduced `WebDriverInterface`, only
7885
core design solutions and library interfaces are defined.
7986

80-
[Unreleased]: https://github.com/itnelo/reactphp-webdriver/compare/0.2.0...0.x
87+
[Unreleased]: https://github.com/itnelo/reactphp-webdriver/compare/0.2.1...0.x
88+
[0.2.1]: https://github.com/itnelo/reactphp-webdriver/compare/0.2.0..0.2.1
8189
[0.2.0]: https://github.com/itnelo/reactphp-webdriver/compare/0.1.0..0.2.0
8290
[0.1.0]: https://github.com/itnelo/reactphp-webdriver/releases/tag/0.1.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ $socketConnector = new SocketConnector(
8686
'verify_peer' => false,
8787
'verify_peer_name' => false,
8888
],
89-
],
89+
]
9090
);
9191
$browser = new Browser($loop, $socketConnector);
9292
$browser = $browser->withRejectErrorResponse(false);

src/Routine/Condition/CheckRoutine.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ private function runInternal(callable $conditionMetCallback, float $checkInterva
127127
// handling evaluation results.
128128
$this->_isEvaluating = true;
129129
$resultPromise->then(
130-
function () use ($evaluationDeferred) {
131-
// at some point, a promise has been successfully resolved.
132-
$evaluationDeferred->resolve(null);
130+
function ($value) use ($evaluationDeferred) {
131+
// at some point, a promise has been successfully resolved (preserving resval).
132+
$evaluationDeferred->resolve($value);
133133
},
134134
function (Throwable $rejectionReason) {
135135
// signals that we can take another promise from the condition callback to continue our checks.
@@ -154,11 +154,11 @@ function (Throwable $rejectionReason) {
154154
);
155155

156156
return $conditionMetTimedPromise->then(
157-
function () {
157+
function ($value) {
158158
// cleaning up a related timer with condition-check logic.
159159
$this->loop->cancelTimer($this->_evaluationTimer);
160160

161-
return null;
161+
return $value;
162162
},
163163
function (Throwable $rejectionReason) {
164164
$this->loop->cancelTimer($this->_evaluationTimer);

src/WebDriverInterface.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ public function wait(float $time = 30.0): PromiseInterface;
7575
* A condition callback must return an instance of PromiseInterface. Whenever that promise becomes rejected, driver
7676
* will try to get a new promise from the callback, until it reaches a given timeout for retry attempts.
7777
*
78-
* Note: waitUntil itself doesn't apply any timeouts for a single result promise (check iteration), the user-side
78+
* Note 1: waitUntil itself doesn't apply any timeouts for a single result promise (check iteration), the user-side
7979
* MUST control any kind of promise timeouts for the condition callback, which is supplied to the method.
8080
*
81+
* Note 2: the resulting value for the waitUntil promise will be a value, which is forwarded by the condition
82+
* callback (see an example below).
83+
*
8184
* Usage example:
8285
*
8386
* ```
@@ -90,16 +93,21 @@ public function wait(float $time = 30.0): PromiseInterface;
9093
* if (!$isVisible) {
9194
* throw new RuntimeException("Not visible yet! Let's retry!");
9295
* }
96+
*
97+
* // this value will be forwarded as a "result value" for the waitUntil promise.
98+
* return 'it is visible now!';
9399
* }
94100
* );
95101
* },
96102
* 15.5
97103
* );
98104
*
99105
* $becomeVisiblePromise->then(
100-
* function () use ($webDriver) {
106+
* function (string $forwardedValue) use ($webDriver) {
101107
* // try-catch
102108
* $webDriver->clickElement(...); // sending a click command only if we are sure the target is visible.
109+
*
110+
* // $forwardedValue === 'it is visible now!'
103111
* }
104112
* // handle case when the element is not visible on the page
105113
* );
@@ -109,7 +117,7 @@ public function wait(float $time = 30.0): PromiseInterface;
109117
* @param float $time Time (in seconds) to wait for successfully resolved promise from the
110118
* condition callback (minimum: 0.5)
111119
*
112-
* @return PromiseInterface<null>
120+
* @return PromiseInterface<mixed>
113121
*/
114122
public function waitUntil(callable $conditionMetCallback, float $time = 30.0): PromiseInterface;
115123

@@ -118,7 +126,7 @@ public function waitUntil(callable $conditionMetCallback, float $time = 30.0): P
118126
* {filePath}, rejection reason with error message will be provided otherwise.
119127
*
120128
* @param string $sessionIdentifier Session identifier for Selenium Grid server (hub)
121-
* @param string $filePath Path where a screenshot image will be saved
129+
* @param string $filePath Path, where a screenshot image must be saved
122130
*
123131
* @return PromiseInterface<null>
124132
*/

0 commit comments

Comments
 (0)