Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix minkphp#9: Selenium2Driver::getValue returns "undefined" for <tex…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krasilnikov committed Apr 5, 2012
1 parent e2365be commit abd7fbf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Behat/Mink/Driver/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public function getValue($xpath)
var node = {{ELEMENT}},
tagName = node.tagName;
if (tagName == "INPUT") {
if (tagName == "INPUT" || "TEXTAREA" == tagName) {
var type = node.getAttribute('type');
if (type == "checkbox") {
value = "boolean:" + node.checked;
Expand All @@ -489,8 +489,6 @@ public function getValue($xpath)
} else {
value = "string:" + node.value;
}
} else if (tagName == "TEXTAREA") {
value = "string:" + node.text;
} else if (tagName == "SELECT") {
if (node.getAttribute('multiple')) {
options = [];
Expand Down Expand Up @@ -524,7 +522,7 @@ public function getValue($xpath)

$value = $this->executeJsOnXpath($xpath, $script);
if ($value) {
if (preg_match('/^string:(.*)$/', $value, $vars)) {
if (preg_match('/^string:(.*)$/ms', $value, $vars)) {
return $vars[1];
}
if (preg_match('/^boolean:(.*)$/', $value, $vars)) {
Expand Down
8 changes: 8 additions & 0 deletions tests/Behat/Mink/Driver/Selenium2DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ public function testOtherMouseEvents()
$clicker->mouseOver();
$this->assertEquals('mouse overed', $clicker->getText());
}

public function testIssue215()
{
$session = $this->getSession();
$session->visit($this->pathTo('/issue215.html'));

$this->assertContains("foo\nbar", $session->getPage()->findById('textarea')->getValue());
}
}
17 changes: 17 additions & 0 deletions tests/Behat/Mink/Driver/web-fixtures/issue215.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Index page</title>
</head>
<body>

<form action="#">
<textarea rows="10" cols="10" id="textarea">
foo
bar
</textarea>
</form>

</body>
</html>

0 comments on commit abd7fbf

Please sign in to comment.