Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fieldValueEquals fails on textarea with goutte driver #713

Open
ifdattic opened this issue Aug 11, 2016 · 7 comments
Open

fieldValueEquals fails on textarea with goutte driver #713

ifdattic opened this issue Aug 11, 2016 · 7 comments

Comments

@ifdattic
Copy link

ifdattic commented Aug 11, 2016

Assuming you have HTML with textarea containing a value:

<textarea id="comment" class="form-control" rows="3">Very well done with a few typos</textarea>

And you run the following in the step:

$this->assertSession()->fieldValueEquals('comment', $comment);

It would fail with Goutte driver as the value is null. This would work fine with Selenium driver. In my opinion it should work in both cases as you're not using any JS and the markup is correct.

Bellow is the dumps of the following lines:

$commentField = $this->assertSession()->elementExists('css', '#comment');

var_dump($commentField->getText());
var_dump($commentField->getValue());
# with goutte driver
/home/vagrant/peerfeedback/features/bootstrap/StudentFeedbackContext.php:89:
string(31) "Very well done with a few typos"
/home/vagrant/peerfeedback/features/bootstrap/StudentFeedbackContext.php:90:
NULL

# with selenium driver
/home/vagrant/peerfeedback/features/bootstrap/StudentFeedbackContext.php:89:
string(31) "Very well done with a few typos"
/home/vagrant/peerfeedback/features/bootstrap/StudentFeedbackContext.php:90:
string(31) "Very well done with a few typos"
@aik099
Copy link
Member

aik099 commented Aug 11, 2016

This seems to known limitation of Goutte driver because of underlying BrowserKit driver is treating {{ like template placeholders. I'm not 100% sure, that this is the case here, but it might be.

@ifdattic
Copy link
Author

@aik099 Forgot to change that one, it's actually the Twig variable so on the normal page it's just normal Very well done with a few typos text.

@aik099
Copy link
Member

aik099 commented Aug 12, 2016

So this is isn't a problem anymore?

@ifdattic
Copy link
Author

No, it's still the same issue. I just meant that it's actually normal text in HTML so {{ are not there to be treated as template placeholders.

@aik099
Copy link
Member

aik099 commented Aug 12, 2016

There is a test in driver test suite, that confirms, that Goutte can get current value from textarea (presuming that textarea initially had that value in HTML and it wasn't set later using JavaScript): https://github.com/minkphp/Mink/blob/master/driver-testsuite/tests/Form/GeneralTest.php#L168 (analog to $commentField->getValue() code from your example).

  • Maybe HTML markup of page you're testing is broken and being headless Goutte can't properly parse HTML and detect value inside textarea?
  • Or maybe you have 2 textareas with same name on the page?

@ifdattic
Copy link
Author

That scenario needs any JavaScript (that is how I found this as after removing the @javascript tag it started to fail).

There was a few markup issues, but after fixing them the issue was not fixed.

No, there is only a single textarea on that page.

@aik099
Copy link
Member

aik099 commented Aug 12, 2016

Maybe you can add failing test (via PR) in https://github.com/minkphp/Mink/tree/master/driver-testsuite that will demonstrate the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants