Skip to content

Commit d64c9c2

Browse files
committed
describing an interface for the async webdriver client, method stubs
1 parent e4e36fc commit d64c9c2

4 files changed

Lines changed: 450 additions & 3 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
.idea/
2+
3+
vendor/
4+
composer.lock

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@
1515
],
1616
"autoload": {
1717
"psr-4": {
18-
"Itnelo\\React\\": [
18+
"Itnelo\\React\\WebDriver\\": [
1919
"src/"
2020
]
2121
}
2222
},
2323
"minimum-stability": "stable",
2424
"require": {
25-
"php": ">=7.4"
25+
"php": ">=7.4",
26+
"react/promise": "^2.8"
2627
},
2728
"config": {
2829
"sort-packages": true
2930
},
3031
"extra": {
3132
"branch-alias": {
32-
"dev-master": "0.1-dev"
33+
"dev-master": "0.x-dev"
3334
}
3435
}
3536
}

src/Client/W3CClient.php

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the ReactPHP WebDriver <https://github.com/itnelo/reactphp-webdriver>.
5+
*
6+
* (c) 2020 Pavel Petrov <itnelo@gmail.com>.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @license https://opensource.org/licenses/mit MIT
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace Itnelo\React\WebDriver\Client;
17+
18+
use Itnelo\React\WebDriver\ClientInterface;
19+
use React\Promise\PromiseInterface;
20+
21+
/**
22+
* W3C compliant WebDriver client for Selenium Grid server (hub) that performs asynchronously.
23+
*
24+
* This is a direct port of RemoteWebDriver logic from the "php-webdriver/webdriver" package, which utilizes
25+
* ReactPHP event loop and promise API for browser interaction w/o execution flow blocking.
26+
*
27+
* It isn't a complete bridge and gives only the most common and robust levers to make the job done. For more info see
28+
* {@link ClientInterface}.
29+
*
30+
* @see https://github.com/php-webdriver/php-webdriver/blob/1.8.3/lib/Remote/RemoteWebDriver.php
31+
*/
32+
class W3CClient implements ClientInterface
33+
{
34+
/**
35+
* {@inheritDoc}
36+
*/
37+
public function getSessionIdentifiers(): PromiseInterface
38+
{
39+
// TODO: Implement getSessionIdentifiers() method.
40+
}
41+
42+
/**
43+
* {@inheritDoc}
44+
*/
45+
public function createSession(): PromiseInterface
46+
{
47+
// TODO: Implement createSession() method.
48+
}
49+
50+
/**
51+
* {@inheritDoc}
52+
*/
53+
public function removeSession(string $sessionIdentifier): PromiseInterface
54+
{
55+
// TODO: Implement removeSession() method.
56+
}
57+
58+
/**
59+
* {@inheritDoc}
60+
*/
61+
public function getTabIdentifiers(string $sessionIdentifier): PromiseInterface
62+
{
63+
// TODO: Implement getTabIdentifiers() method.
64+
}
65+
66+
/**
67+
* {@inheritDoc}
68+
*/
69+
public function getActiveTabIdentifier(string $sessionIdentifier): PromiseInterface
70+
{
71+
// TODO: Implement getActiveTabIdentifier() method.
72+
}
73+
74+
/**
75+
* {@inheritDoc}
76+
*/
77+
public function setActiveTab(string $sessionIdentifier, string $tabIdentifier): PromiseInterface
78+
{
79+
// TODO: Implement setActiveTab() method.
80+
}
81+
82+
/**
83+
* {@inheritDoc}
84+
*/
85+
public function openUri(string $sessionIdentifier, string $uri): PromiseInterface
86+
{
87+
// TODO: Implement openUri() method.
88+
}
89+
90+
/**
91+
* {@inheritDoc}
92+
*/
93+
public function getUri(string $sessionIdentifier): PromiseInterface
94+
{
95+
// TODO: Implement getUri() method.
96+
}
97+
98+
/**
99+
* {@inheritDoc}
100+
*/
101+
public function getSource(string $sessionIdentifier): PromiseInterface
102+
{
103+
// TODO: Implement getSource() method.
104+
}
105+
106+
/**
107+
* {@inheritDoc}
108+
*/
109+
public function getElementIdentifier(string $sessionIdentifier, string $xpathQuery): PromiseInterface
110+
{
111+
// TODO: Implement getElementIdentifier() method.
112+
}
113+
114+
/**
115+
* {@inheritDoc}
116+
*/
117+
public function getActiveElement(string $sessionIdentifier): PromiseInterface
118+
{
119+
// TODO: Implement getActiveElement() method.
120+
}
121+
122+
/**
123+
* {@inheritDoc}
124+
*/
125+
public function getElementVisibility(string $sessionIdentifier, array $elementIdentifier): PromiseInterface
126+
{
127+
// TODO: Implement getElementVisibility() method.
128+
}
129+
130+
/**
131+
* {@inheritDoc}
132+
*/
133+
public function clickElement(string $sessionIdentifier, array $elementIdentifier): PromiseInterface
134+
{
135+
// TODO: Implement clickElement() method.
136+
}
137+
138+
/**
139+
* {@inheritDoc}
140+
*/
141+
public function keypressElement(
142+
string $sessionIdentifier,
143+
array $elementIdentifier,
144+
string $keySequence
145+
): PromiseInterface {
146+
// TODO: Implement keypressElement() method.
147+
}
148+
149+
/**
150+
* {@inheritDoc}
151+
*/
152+
public function mouseMove(
153+
string $sessionIdentifier,
154+
int $offsetX,
155+
int $offsetY,
156+
int $moveDuration = 100,
157+
array $startingPoint = null
158+
): PromiseInterface {
159+
// TODO: Implement mouseMove() method.
160+
}
161+
162+
/**
163+
* {@inheritDoc}
164+
*/
165+
public function mouseLeftClick(string $sessionIdentifier): PromiseInterface
166+
{
167+
// TODO: Implement mouseLeftClick() method.
168+
}
169+
170+
/**
171+
* {@inheritDoc}
172+
*/
173+
public function getScreenshot(string $sessionIdentifier): PromiseInterface
174+
{
175+
// TODO: Implement getScreenshot() method.
176+
}
177+
}

0 commit comments

Comments
 (0)