Skip to content

Commit

Permalink
Merge branch '1.3-test-v2' into macos
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-andreyev committed Jul 12, 2023
2 parents 24f6ca7 + d6deb57 commit 07feb70
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
on:
push:
branches:
- master
pull_request:
branches:
- master
push: ~

env:
DRIVER_URL: "http://localhost:4444"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Follow https://github.com/shivammathur/setup-php#local-testing-setup
## Copyright

Copyright (c) 2023 Oleg Andreyev <oleg@andreyev.lv>

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"require-dev": {
"ext-json": "*",
"roave/security-advisories": "dev-master",
"mink/driver-testsuite": "dev-integration-branch",
"mink/driver-testsuite": "dev-integration-branch-v2",
"behat/mink-extension": "^2.3",
"bamarni/composer-bin-plugin": "^1.8",
"jetbrains/phpstorm-attributes": "^1.0"
Expand Down
30 changes: 28 additions & 2 deletions src/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,8 @@ public function getValue(
}

/**
* @param string $xpath
* @param string|string[] $value
* @param string $xpath
* @param string|bool|string[] $value
*
* @return void
*
Expand All @@ -705,6 +705,10 @@ public function setValue(
$elementName = strtolower($element->getTagName());

if ('select' === $elementName) {
if (!is_string($value) && !is_array($value)) {
throw new DriverException(sprintf('Impossible to set value an element with XPath "%s" as the value is not a string or an array.', $xpath));
}

$select = new WebDriverSelect($element);

if (is_array($value)) {
Expand Down Expand Up @@ -737,13 +741,21 @@ public function setValue(
}

if ('radio' === $elementType) {
if (!is_string($value)) {
throw new DriverException('Radio button value must be a string.');
}

$radios = new WebDriverRadios($element);
$radios->selectByValue($value);

return;
}

if ('file' === $elementType) {
if (!is_string($value)) {
throw new DriverException('File name must be a string.');
}

$this->attachFile($xpath, $value);

return;
Expand All @@ -765,6 +777,20 @@ public function setValue(

return;
}

if (
'text' === $elementType
&& !is_string($value)
) {
throw new DriverException(sprintf('Impossible to set value with type %s an element with XPath "%s" of input[type=text]', gettype($value), $xpath));
}
}

if (
'textarea' === $elementName
&& !is_string($value)
) {
throw new DriverException(sprintf('Impossible to set value with type %s an element with XPath "%s" of textarea', gettype($value), $xpath));
}

$value = (string) $value;
Expand Down

0 comments on commit 07feb70

Please sign in to comment.