Skip to content

Commit b219a04

Browse files
authored
Merge pull request #334 from alexpott/fix-PHP8.1
Fix PHP 8.1 deprecation
2 parents 4a4d1af + 96ba5d7 commit b219a04

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Selenium2Driver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public function getValue($xpath)
579579
{
580580
$element = $this->findElement($xpath);
581581
$elementName = strtolower($element->name());
582-
$elementType = strtolower($element->attribute('type'));
582+
$elementType = strtolower($element->attribute('type') ?: '');
583583

584584
// Getting the value of a checkbox returns its value if selected.
585585
if ('input' === $elementName && 'checkbox' === $elementType) {
@@ -657,7 +657,7 @@ public function setValue($xpath, $value)
657657
}
658658

659659
if ('input' === $elementName) {
660-
$elementType = strtolower($element->attribute('type'));
660+
$elementType = strtolower($element->attribute('type') ?: '');
661661

662662
if (in_array($elementType, array('submit', 'image', 'button', 'reset'))) {
663663
throw new DriverException(sprintf('Impossible to set value an element with XPath "%s" as it is not a select, textarea or textbox', $xpath));
@@ -756,7 +756,7 @@ public function selectOption($xpath, $value, $multiple = false)
756756
$element = $this->findElement($xpath);
757757
$tagName = strtolower($element->name());
758758

759-
if ('input' === $tagName && 'radio' === strtolower($element->attribute('type'))) {
759+
if ('input' === $tagName && 'radio' === strtolower($element->attribute('type') ?: '')) {
760760
$this->selectRadioValue($element, $value);
761761

762762
return;
@@ -1147,7 +1147,7 @@ private function deselectAllOptions(Element $element)
11471147
*/
11481148
private function ensureInputType(Element $element, $xpath, $type, $action)
11491149
{
1150-
if ('input' !== strtolower($element->name()) || $type !== strtolower($element->attribute('type'))) {
1150+
if ('input' !== strtolower($element->name()) || $type !== strtolower($element->attribute('type') ?: '')) {
11511151
$message = 'Impossible to %s the element with XPath "%s" as it is not a %s input';
11521152

11531153
throw new DriverException(sprintf($message, $action, $xpath, $type));

0 commit comments

Comments
 (0)