Skip to content

Commit 39a6e99

Browse files
committed
allowing int type for the 'command.timeout' driver option; with float normalizer,
README: minimal configuration is described
1 parent 52cf4e1 commit 39a6e99

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,27 @@ $ composer require itnelo/reactphp-webdriver:0.x@dev
3232

3333
## How to use
3434

35-
Call a factory method to get your instance (recommended):
35+
Call a factory method to get your instance (recommended). The minimal configuration is:
36+
37+
```php
38+
use React\EventLoop\Factory as LoopFactory;
39+
use Itnelo\React\WebDriver\WebDriverFactory;
40+
41+
$loop = LoopFactory::create();
42+
43+
$webDriver = WebDriverFactory::create(
44+
$loop,
45+
[
46+
'hub' => [
47+
'host' => 'selenium-hub',
48+
'port' => 4444,
49+
],
50+
]
51+
);
52+
```
53+
54+
You can customize a set of parameters for the underlying [ReactPHP Browser](https://github.com/reactphp/http#browser)
55+
and tune driver options:
3656

3757
```php
3858
use React\EventLoop\Factory as LoopFactory;
@@ -45,7 +65,7 @@ $webDriver = WebDriverFactory::create(
4565
[
4666
'browser' => [
4767
'tcp' => [
48-
'bindto' => '192.168.56.10:0',
68+
'bindto' => '192.169.56.10:0',
4969
],
5070
'tls' => [
5171
'verify_peer' => false,
@@ -63,7 +83,7 @@ $webDriver = WebDriverFactory::create(
6383
);
6484
```
6585

66-
Manual configuration (if you want to configure each component as a separate service, e.g. compiling a DI container
86+
Manual configuration (if you prefer to configure each component as a separate service, e.g. compiling a DI container
6787
and want to reuse existing service definitions):
6888

6989
```php
@@ -80,7 +100,7 @@ $socketConnector = new SocketConnector(
80100
$loop,
81101
[
82102
'tcp' => [
83-
'bindto' => '192.168.56.10:0',
103+
'bindto' => '192.169.56.10:0',
84104
],
85105
'tls' => [
86106
'verify_peer' => false,

src/WebDriverFactory.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use React\Http\Browser;
2222
use React\Socket\Connector as SocketConnector;
2323
use Symfony\Component\OptionsResolver\Exception\ExceptionInterface as ConfigurationExceptionInterface;
24+
use Symfony\Component\OptionsResolver\Options;
2425
use Symfony\Component\OptionsResolver\OptionsResolver;
2526

2627
/**
@@ -41,7 +42,7 @@ final class WebDriverFactory
4142
* [
4243
* 'browser' => [
4344
* 'tcp' => [
44-
* 'bindto' => '192.168.56.10:0',
45+
* 'bindto' => '192.169.56.10:0',
4546
* ],
4647
* 'tls' => [
4748
* 'verify_peer' => false,
@@ -108,8 +109,16 @@ function (OptionsResolver $commandOptionsResolver) {
108109
'Maximum time to wait (in seconds) for command execution '
109110
. '(do not correlate with HTTP timeouts)'
110111
)
111-
->allowedTypes('float')
112+
->allowedTypes('int', 'float')
112113
->default(30.0)
114+
->normalize(
115+
function (Options $options, $commandTimeout) {
116+
$commandTimeoutNormalized = (float) $commandTimeout;
117+
$commandTimeoutNormalized = max(0.1, $commandTimeoutNormalized);
118+
119+
return $commandTimeoutNormalized;
120+
}
121+
)
113122
;
114123
}
115124
)

0 commit comments

Comments
 (0)