How do i implement methods for FeatureContext.php in Behat ?
lets say we have a method:
/**
* @When /^I request "(GET|PUT|POST|DELETE|PATCH) ([^"]*)"$/
*/
public function iRequest($httpMethod, $resource)
{
$this->resource = $resource;
$method = strtolower($httpMethod);
try {
switch ($httpMethod) {
case 'PUT':
case 'POST':
$this->response = $this
->client
->$method($resource, null, $this->requestPayload);
break;
default:
$this->response = $this
->client
->$method($resource);
}
} catch (BadResponseException $e) {
$response = $e->getResponse();
// Sometimes the request will fail, at which point we have
// no response at all. Let Guzzle give an error here, it's
// pretty self-explanatory.
if ($response === null) {
throw $e;
}
$this->response = $e->getResponse();
}
}
for $method = strtolower($httpMethod); where do i get information about strtolower() method, or info about getResponse()
i´m getting an error on ckeditor the id is dynamic and i cannot use it in this function /**
@Then I fill in wysiwyg on field :locator with :value
*/public function iFillInWysiwygOnFieldWith($locator, $value) {
$el = $this->getSession()->getPage()->findField($locator);
if (empty($el)) {
throw new ExpectationException('Could not find WYSIWYG with locator: ' . $locator, $this->getSession());
}
$fieldId = $el->getAttribute('id');
if (empty($fieldId)) {
throw new Exception('Could not find an id for field with locator: ' . $locator);
}
$this->getSession()
->executeScript("CKEDITOR.instances[\"$fieldId\"].setData(\"$value\");");
}
/* @Then I fill in wysiwyg on fi... by Frederico Pinheiro Carvalho
Frederico Pinheiro Carvalho
3:36 PM
/**
@Then I fill in wysiwyg on field :locator with :value
*/public function iFillInWysiwygOnFieldWith($locator, $value) {
$el = $this->getSession()->getPage()->findField($locator);
if (empty($el)) {
throw new ExpectationException('Could not find WYSIWYG with locator: ' . $locator, $this->getSession());
}
$fieldId = $el->getAttribute('id');
if (empty($fieldId)) {
throw new Exception('Could not find an id for field with locator: ' . $locator);
}
$this->getSession()
->executeScript("CKEDITOR.instances[\"$fieldId\"].setData(\"$value\");");
}
Message by Frederico Pinheiro Carvalho
Frederico Pinheiro Carvalho3:39 PM
https://gitter.im/Behat/Behat?at=5a80eac77084124a3465b3a9
Url Preview for Behat/Behat
Behat/Behat
@mossy2100: Hi - I am trying to use behat to set the value of a Body field on a form, except the field is a CKEditor rich text WYSIWYG field, which uses an iframe. Any tips?
gitter.im
Hey team, we are upgrading from behat/behat
v2.5.5 up to v3.8.1 and I've got a quick question. Most things I've been able to bring up, but I can't find an equivalent to one thing we do. We have a couple of steps that are just convenience steps. For example Given I accept the terms of service
, where the PHP code for that looks like:
/**
* @Given /^I accept the terms of service$/
*/
public function iAcceptTermsOfService()
{
return [
new Step\Given("the \"HasAcceptedTerms\" checkbox is not checked"),
new Step\When("I check \"HasAcceptedTerms\""),
new Step\Then("I should see \"You must review the terms before you can continue.\""),
]; // Continues on but you get the idea
}
Is there any similar feature of v3? Is it implementing or returning a custom StepNode
perhaps?
behatch/contexts
package is abandoned, some forks as well. I'm curious if I have missed something and we have everything natively in Behat or at some other package (friends-of-behat
, etc) or what happened? Any suggestion what to use instead?
FeatureContext
context class not found and can not be used." error upon trying to run it the first time. I see that this is a known problem but so far have not understood the proposed solutions I can find. Hoping somone has a minute or two to assist? Thank you!
Hi all, I'm new to behat and I'm trying to create tests for symfony 4.4.
I'm trying to write my first test when a user is authenticated and I've found this helper (https://robinvdvleuten.nl/blog/handle-authenticated-users-in-behat-mink/), but I can't figure out how to get the BrowserKitDriver. I've required behat/mink-browserkit-driver
but no luck. I've tried multiple settings in the behat.yml file, but nothing.
default:
suites:
default:
contexts:
- DemoContext
extensions:
FriendsOfBehat\SymfonyExtension: ~
Behat\MinkExtension:
base_url: https://....
sessions:
default:
symfony: ~
# browserkit: ~ ## doesn't understand this
Any and all pointers/help would be greatly appreciated.