| @@ 107-132 (lines=26) @@ | ||
| 104 | * @param string $tags |
|
| 105 | * @return array<\DataSift\WebDriver\WebDriverElement> |
|
| 106 | */ |
|
| 107 | public function getElementsByAltText($text, $tags = '*') |
|
| 108 | { |
|
| 109 | // what are we doing? |
|
| 110 | $tag = $this->convertTagsToString($tags); |
|
| 111 | $log = usingLog()->startAction("get '{$tag}' elements with alt text '{$text}'"); |
|
| 112 | ||
| 113 | // prepare the list of tags |
|
| 114 | if (is_string($tags)) { |
|
| 115 | $tags = array($tags); |
|
| 116 | } |
|
| 117 | ||
| 118 | // build up the xpath to use |
|
| 119 | $xpathList = array(); |
|
| 120 | foreach ($tags as $tag) { |
|
| 121 | $xpathList[] = 'descendant::' . $tag . '[@alt = "' . $text . '"]'; |
|
| 122 | } |
|
| 123 | ||
| 124 | // get the possibly matching elements |
|
| 125 | $elements = $this->getElementsByXpath($xpathList); |
|
| 126 | ||
| 127 | // log the result |
|
| 128 | $log->endAction(count($elements) . " element(s) found"); |
|
| 129 | ||
| 130 | // return the elements |
|
| 131 | return $elements; |
|
| 132 | } |
|
| 133 | ||
| 134 | /** |
|
| 135 | * @param string $class |
|
| @@ 139-164 (lines=26) @@ | ||
| 136 | * @param string $tags |
|
| 137 | * @return array<\DataSift\WebDriver\WebDriverElement> |
|
| 138 | */ |
|
| 139 | public function getElementsByClass($class, $tags = '*') |
|
| 140 | { |
|
| 141 | // what are we doing? |
|
| 142 | $tag = $this->convertTagsToString($tags); |
|
| 143 | $log = usingLog()->startAction("get '{$tag}' elements with CSS class '{$class}'"); |
|
| 144 | ||
| 145 | // prepare the list of tags |
|
| 146 | if (is_string($tags)) { |
|
| 147 | $tags = array($tags); |
|
| 148 | } |
|
| 149 | ||
| 150 | // build up the xpath to use |
|
| 151 | $xpathList = array(); |
|
| 152 | foreach ($tags as $tag) { |
|
| 153 | $xpathList[] = 'descendant::' . $tag . '[contains(concat(" ", normalize-space(@class), " "), " ' . $class . ' ")]'; |
|
| 154 | } |
|
| 155 | ||
| 156 | // find the matches |
|
| 157 | $elements = $this->getElementsByXpath($xpathList); |
|
| 158 | ||
| 159 | // log the result |
|
| 160 | $log->endAction(count($elements) . " element(s) found"); |
|
| 161 | ||
| 162 | // return the elements |
|
| 163 | return $elements; |
|
| 164 | } |
|
| 165 | ||
| 166 | /** |
|
| 167 | * @param string $id |
|
| @@ 171-196 (lines=26) @@ | ||
| 168 | * @param string $tags |
|
| 169 | * @return array<\DataSift\WebDriver\WebDriverElement> |
|
| 170 | */ |
|
| 171 | public function getElementsById($id, $tags = '*') |
|
| 172 | { |
|
| 173 | // what are we doing? |
|
| 174 | $tag = $this->convertTagsToString($tags); |
|
| 175 | $log = usingLog()->startAction("get '{$tag}' elements with id '{$id}'"); |
|
| 176 | ||
| 177 | // prepare the list of tags |
|
| 178 | if (is_string($tags)) { |
|
| 179 | $tags = array($tags); |
|
| 180 | } |
|
| 181 | ||
| 182 | // build up the xpath to use |
|
| 183 | $xpathList = array(); |
|
| 184 | foreach ($tags as $tag) { |
|
| 185 | $xpathList[] = 'descendant::' . $tag . '[@id = "' . $id . '"]'; |
|
| 186 | } |
|
| 187 | ||
| 188 | // find the matches |
|
| 189 | $elements = $this->getElementsByXpath($xpathList); |
|
| 190 | ||
| 191 | // log the result |
|
| 192 | $log->endAction(count($elements) . " element(s) found"); |
|
| 193 | ||
| 194 | // return the elements |
|
| 195 | return $elements; |
|
| 196 | } |
|
| 197 | ||
| 198 | /** |
|
| 199 | * @param string $labelText |
|
| @@ 381-406 (lines=26) @@ | ||
| 378 | * @param string $tags |
|
| 379 | * @return array<\DataSift\WebDriver\WebDriverElement> |
|
| 380 | */ |
|
| 381 | public function getElementsByName($name, $tags = '*') |
|
| 382 | { |
|
| 383 | // what are we doing? |
|
| 384 | $tag = $this->convertTagsToString($tags); |
|
| 385 | $log = usingLog()->startAction("get '{$tag}' elements with name '{$name}'"); |
|
| 386 | ||
| 387 | // prepare the list of tags |
|
| 388 | if (is_string($tags)) { |
|
| 389 | $tags = array($tags); |
|
| 390 | } |
|
| 391 | ||
| 392 | // build up the xpath to use |
|
| 393 | $xpathList = array(); |
|
| 394 | foreach ($tags as $tag) { |
|
| 395 | $xpathList[] = 'descendant::' . $tag . '[@name = "' . $name . '"]'; |
|
| 396 | } |
|
| 397 | ||
| 398 | // find the matches |
|
| 399 | $elements = $this->getElementsByXpath($xpathList); |
|
| 400 | ||
| 401 | // log the result |
|
| 402 | $log->endAction(count($elements) . " element(s) found"); |
|
| 403 | ||
| 404 | // return the elements |
|
| 405 | return $elements; |
|
| 406 | } |
|
| 407 | ||
| 408 | /** |
|
| 409 | * @param string $text |
|
| @@ 413-438 (lines=26) @@ | ||
| 410 | * @param string $tags |
|
| 411 | * @return array<\DataSift\WebDriver\WebDriverElement> |
|
| 412 | */ |
|
| 413 | public function getElementsByPlaceholder($text, $tags = '*') |
|
| 414 | { |
|
| 415 | // what are we doing? |
|
| 416 | $tag = $this->convertTagsToString($tags); |
|
| 417 | $log = usingLog()->startAction("get '{$tag}' element with placeholder '{$text}'"); |
|
| 418 | ||
| 419 | // prepare the list of tags |
|
| 420 | if (is_string($tags)) { |
|
| 421 | $tags = array($tags); |
|
| 422 | } |
|
| 423 | ||
| 424 | // build up the xpath to use |
|
| 425 | $xpathList = array(); |
|
| 426 | foreach ($tags as $tag) { |
|
| 427 | $xpathList[] = 'descendant::' . $tag . '[@placeholder = "' . $text . '"]'; |
|
| 428 | } |
|
| 429 | ||
| 430 | // get the possibly matching elements |
|
| 431 | $elements = $this->getElementsByXpath($xpathList); |
|
| 432 | ||
| 433 | // log the result |
|
| 434 | $log->endAction(count($elements) . " element(s) found"); |
|
| 435 | ||
| 436 | // return the elements |
|
| 437 | return $elements; |
|
| 438 | } |
|
| 439 | ||
| 440 | /** |
|
| 441 | * @param string $text |
|
| @@ 485-510 (lines=26) @@ | ||
| 482 | * @param string $tags |
|
| 483 | * @return array<\DataSift\WebDriver\WebDriverElement> |
|
| 484 | */ |
|
| 485 | public function getElementsByTitle($title, $tags = '*') |
|
| 486 | { |
|
| 487 | // what are we doing? |
|
| 488 | $tag = $this->convertTagsToString($tags); |
|
| 489 | $log = usingLog()->startAction("get '{$tag}' element with title '{$title}'"); |
|
| 490 | ||
| 491 | // prepare the list of tags |
|
| 492 | if (is_string($tags)) { |
|
| 493 | $tags = array($tags); |
|
| 494 | } |
|
| 495 | ||
| 496 | // build up the xpath to use |
|
| 497 | $xpathList = array(); |
|
| 498 | foreach ($tags as $tag) { |
|
| 499 | $xpathList[] = 'descendant::' . $tag . '[@title = "' . $title . '"]'; |
|
| 500 | } |
|
| 501 | ||
| 502 | // search using the xpath |
|
| 503 | $elements = $this->getElementsByXpath($xpathList); |
|
| 504 | ||
| 505 | // log the result |
|
| 506 | $log->endAction(count($elements) . " element(s) found"); |
|
| 507 | ||
| 508 | // return the elements |
|
| 509 | return $elements; |
|
| 510 | } |
|
| 511 | ||
| 512 | /** |
|
| 513 | * @param array<string> $xpathList |
|