-
Notifications
You must be signed in to change notification settings - Fork 290
Expand file tree
/
Copy pathElementInterface.php
More file actions
111 lines (101 loc) · 3.12 KB
/
ElementInterface.php
File metadata and controls
111 lines (101 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/*
* This file is part of the Mink package.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Behat\Mink\Element;
/**
* Element interface.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface ElementInterface
{
/**
* Returns XPath for handled element.
*
* @return string
*/
public function getXpath();
/**
* Checks whether element with specified selector exists inside the current element.
*
* @param string $selector selector engine name
* @param string|array $locator selector locator
*
* @return bool
*
* @see ElementInterface::findAll for the supported selectors
*/
public function has(string $selector, $locator);
/**
* Checks if an element still exists in the DOM.
*
* @return bool
*/
public function isValid();
/**
* Waits for a value to be available and returns it.
*
* A falsy value returned by the callback is considered not found and will
* retry after some waiting time, until a value is found or the timeout is
* reached.
* When the timeout is reached, the falsy value of the last attempt is returned.
*
* @template T
*
* @param int|float $timeout Maximal allowed waiting time in seconds.
* @param callable(static): T $callback Callback, which result is both used as waiting condition and returned.
* Will receive reference to `this element` as first argument.
*
* @return mixed
*
* @phpstan-return T
*/
public function waitFor($timeout, callable $callback);
/**
* Finds first element with specified selector inside the current element.
*
* @param string $selector selector engine name
* @param string|array $locator selector locator
*
* @return NodeElement|null
*
* @see ElementInterface::findAll for the supported selectors
*/
public function find(string $selector, $locator);
/**
* Finds all elements with specified selector inside the current element.
*
* Valid selector engines are named, xpath, css, named_partial and named_exact.
*
* 'named' is a pseudo selector engine which prefers an exact match but
* will return a partial match if no exact match is found.
* 'xpath' is a pseudo selector engine supported by SelectorsHandler.
*
* More selector engines can be registered in the SelectorsHandler.
*
* @param string $selector selector engine name
* @param string|array $locator selector locator
*
* @return NodeElement[]
*
* @see NamedSelector for the locators supported by the named selectors
*/
public function findAll(string $selector, $locator);
/**
* Returns element text (inside tag).
*
* @return string
*/
public function getText();
/**
* Returns element inner html.
*
* @return string
*/
public function getHtml();
}