Let's say we have the following HTML code:
<div>
<p id="fruit">Apple</p>
</div>
How do I grab #fruit
and check its inner HTML via codeception?
It seems, that Codeception utilizes either executeJS
or executeInSelenium
(not recommended) in
these kind of situations.
Here is an example using executeJS
with JQuery:
<?php
$fruitVal = $I->executeJS('return $(#fruit).val()');
?>
See more in: Codeception docs: executeJS
Turns out, that there is another, "more natural" way to handle this case:
Here is an example using grabAttributeFrom
method:
<?php
$fruitVal = $I->grabAttributeFrom('#fruit', 'innerHTML');
?>
See more in: Codeception docs: grabAttributeFrom