Hello, I am trying to automate behat test via Gitlab CI. Issue I've got is that in CI and in PHPStorm (executing same tests) I always get WebDriver\Exception\NoSuchElement: Element not found with xpath, //html
. From stack trace, I am not able to find anything. When I try to run locally (docker) via terminal test passes and everything works, but if I try to run then through PHPStorm I get the same error as in CI. I can't figure out what is wrong, it looks like selenium2 is not working correctly. And screenshots generated by test (when using PHPStorm and CI) are 0 byte.
My behat.yml file looks like:
default:
suites:
default:
path: '%paths.base%/features'
contexts:
- App\Tests\Behat\FeatureContext
- Behat\MinkExtension\Context\MinkContext
extensions:
FriendsOfBehat\SymfonyExtension:
bootstrap: tests/bootstrap.php
kernel:
environment: test
local_ff:
extensions:
FriendsOfBehat\SymfonyExtension:
bootstrap: tests/bootstrap.php
kernel:
environment: test
Behat\MinkExtension:
base_url: http://behattest.test
browser_name: firefox
sessions:
firefox:
selenium2:
wd_host: "http://selenium-hub:4444/wd/hub"
browser: firefox
capabilities:
browser: firefox
When running in local terminal (docker) and using local_ff profile it works as expected
New to behat. I've created a feature file, and when I run php behat.phar --init
I get a block of html telling me I've been redirected to githubusercontent.com. I load the url in a browser telling me I've got a bunch of Amz headers missing. Why is it redirecting to githubusercontent? And can I prevent that from happening?
I'm working on a free tier lightsail aws instance if that makes any difference
composer require behat/behat
and then vendor/bin/behat --init
and this will show you what you should see... maybe it is the way you installed or are calling the behat "bin" (which is a phar)
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()