xref: /plugin/combo/vendor/php-webdriver/webdriver/lib/WebDriverSelectInterface.php (revision 04fd306c7c155fa133ebb3669986875d65988276)
1*04fd306cSNickeau<?php
2*04fd306cSNickeau
3*04fd306cSNickeaunamespace Facebook\WebDriver;
4*04fd306cSNickeau
5*04fd306cSNickeauuse Facebook\WebDriver\Exception\NoSuchElementException;
6*04fd306cSNickeauuse Facebook\WebDriver\Exception\UnsupportedOperationException;
7*04fd306cSNickeau
8*04fd306cSNickeau/**
9*04fd306cSNickeau * Models an element of select type, providing helper methods to select and deselect options.
10*04fd306cSNickeau */
11*04fd306cSNickeauinterface WebDriverSelectInterface
12*04fd306cSNickeau{
13*04fd306cSNickeau    /**
14*04fd306cSNickeau     * @return bool Whether this select element support selecting multiple options.
15*04fd306cSNickeau     */
16*04fd306cSNickeau    public function isMultiple();
17*04fd306cSNickeau
18*04fd306cSNickeau    /**
19*04fd306cSNickeau     * @return WebDriverElement[] All options belonging to this select tag.
20*04fd306cSNickeau     */
21*04fd306cSNickeau    public function getOptions();
22*04fd306cSNickeau
23*04fd306cSNickeau    /**
24*04fd306cSNickeau     * @return WebDriverElement[] All selected options belonging to this select tag.
25*04fd306cSNickeau     */
26*04fd306cSNickeau    public function getAllSelectedOptions();
27*04fd306cSNickeau
28*04fd306cSNickeau    /**
29*04fd306cSNickeau     * @throws NoSuchElementException
30*04fd306cSNickeau     *
31*04fd306cSNickeau     * @return WebDriverElement The first selected option in this select tag (or the currently selected option in a
32*04fd306cSNickeau     * normal select)
33*04fd306cSNickeau     */
34*04fd306cSNickeau    public function getFirstSelectedOption();
35*04fd306cSNickeau
36*04fd306cSNickeau    /**
37*04fd306cSNickeau     * Select the option at the given index.
38*04fd306cSNickeau     *
39*04fd306cSNickeau     * @param int $index The index of the option. (0-based)
40*04fd306cSNickeau     *
41*04fd306cSNickeau     * @throws NoSuchElementException
42*04fd306cSNickeau     */
43*04fd306cSNickeau    public function selectByIndex($index);
44*04fd306cSNickeau
45*04fd306cSNickeau    /**
46*04fd306cSNickeau     * Select all options that have value attribute matching the argument. That is, when given "foo" this would
47*04fd306cSNickeau     * select an option like:
48*04fd306cSNickeau     *
49*04fd306cSNickeau     * `<option value="foo">Bar</option>`
50*04fd306cSNickeau     *
51*04fd306cSNickeau     * @param string $value The value to match against.
52*04fd306cSNickeau     *
53*04fd306cSNickeau     * @throws NoSuchElementException
54*04fd306cSNickeau     */
55*04fd306cSNickeau    public function selectByValue($value);
56*04fd306cSNickeau
57*04fd306cSNickeau    /**
58*04fd306cSNickeau     * Select all options that display text matching the argument. That is, when given "Bar" this would
59*04fd306cSNickeau     * select an option like:
60*04fd306cSNickeau     *
61*04fd306cSNickeau     * `<option value="foo">Bar</option>`
62*04fd306cSNickeau     *
63*04fd306cSNickeau     * @param string $text The visible text to match against.
64*04fd306cSNickeau     *
65*04fd306cSNickeau     * @throws NoSuchElementException
66*04fd306cSNickeau     */
67*04fd306cSNickeau    public function selectByVisibleText($text);
68*04fd306cSNickeau
69*04fd306cSNickeau    /**
70*04fd306cSNickeau     * Select all options that display text partially matching the argument. That is, when given "Bar" this would
71*04fd306cSNickeau     * select an option like:
72*04fd306cSNickeau     *
73*04fd306cSNickeau     * `<option value="bar">Foo Bar Baz</option>`
74*04fd306cSNickeau     *
75*04fd306cSNickeau     * @param string $text The visible text to match against.
76*04fd306cSNickeau     *
77*04fd306cSNickeau     * @throws NoSuchElementException
78*04fd306cSNickeau     */
79*04fd306cSNickeau    public function selectByVisiblePartialText($text);
80*04fd306cSNickeau
81*04fd306cSNickeau    /**
82*04fd306cSNickeau     * Deselect all options in multiple select tag.
83*04fd306cSNickeau     *
84*04fd306cSNickeau     * @throws UnsupportedOperationException If the SELECT does not support multiple selections
85*04fd306cSNickeau     */
86*04fd306cSNickeau    public function deselectAll();
87*04fd306cSNickeau
88*04fd306cSNickeau    /**
89*04fd306cSNickeau     * Deselect the option at the given index.
90*04fd306cSNickeau     *
91*04fd306cSNickeau     * @param int $index The index of the option. (0-based)
92*04fd306cSNickeau     * @throws UnsupportedOperationException If the SELECT does not support multiple selections
93*04fd306cSNickeau     */
94*04fd306cSNickeau    public function deselectByIndex($index);
95*04fd306cSNickeau
96*04fd306cSNickeau    /**
97*04fd306cSNickeau     * Deselect all options that have value attribute matching the argument. That is, when given "foo" this would
98*04fd306cSNickeau     * deselect an option like:
99*04fd306cSNickeau     *
100*04fd306cSNickeau     * `<option value="foo">Bar</option>`
101*04fd306cSNickeau     *
102*04fd306cSNickeau     * @param string $value The value to match against.
103*04fd306cSNickeau     * @throws UnsupportedOperationException If the SELECT does not support multiple selections
104*04fd306cSNickeau     */
105*04fd306cSNickeau    public function deselectByValue($value);
106*04fd306cSNickeau
107*04fd306cSNickeau    /**
108*04fd306cSNickeau     * Deselect all options that display text matching the argument. That is, when given "Bar" this would
109*04fd306cSNickeau     * deselect an option like:
110*04fd306cSNickeau     *
111*04fd306cSNickeau     * `<option value="foo">Bar</option>`
112*04fd306cSNickeau     *
113*04fd306cSNickeau     * @param string $text The visible text to match against.
114*04fd306cSNickeau     * @throws UnsupportedOperationException If the SELECT does not support multiple selections
115*04fd306cSNickeau     */
116*04fd306cSNickeau    public function deselectByVisibleText($text);
117*04fd306cSNickeau
118*04fd306cSNickeau    /**
119*04fd306cSNickeau     * Deselect all options that display text matching the argument. That is, when given "Bar" this would
120*04fd306cSNickeau     * deselect an option like:
121*04fd306cSNickeau     *
122*04fd306cSNickeau     * `<option value="foo">Foo Bar Baz</option>`
123*04fd306cSNickeau     *
124*04fd306cSNickeau     * @param string $text The visible text to match against.
125*04fd306cSNickeau     * @throws UnsupportedOperationException If the SELECT does not support multiple selections
126*04fd306cSNickeau     */
127*04fd306cSNickeau    public function deselectByVisiblePartialText($text);
128*04fd306cSNickeau}
129