Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    swaibar
    @swaibar
    @WeeDom I'm not sure how you got there, but to see what you should see... start with a clean folder, run 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)
    @DyanZhao Hello
    @tansiewling-hotmail and welcome to one of the most annoying cases one can come up against... it's simply not possible to remote control the popup as it is main browser. Options are... 1) create an official alternative (i.e. allow login without the popup), 2) same as (1) but unofficial and 3) give up... I hope options 1 or 2 work out for you
    Adrien Cantepie
    @acantepie
    Hi
    Can someone help me ? I am trying to use different parameters on context depending of profile
    swaibar
    @swaibar
    I'm using profiles (i.e. https://docs.behat.org/en/v2.5/guides/7.config.html#profiles) to change things like formatters and tags, what paramters are those you are trying to use?
    kamal2222ahmed
    @kamal2222ahmed

    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()

    kamal2222ahmed
    @kamal2222ahmed
    Is there a way to selenium record in php? Like it is for CC#, Java and Python, using BlazeMeter Recorder
    swaibar
    @swaibar
    @kamal2222ahmed https://www.php.net/manual/en/function.strtolower.php and https://www.php-fig.org/psr/psr-7/ should get you started, I'd advise you invest in PHP knowledge and maybe a decent IDE (i.e. the above is easily found if you follow source declarations in PHPStorm. And I used to use https://www.selenium.dev/selenium-ide/ for "recording" tests. Your existing method of recording should be fine as selenium/webdriver has one interface any method to record the user actions should break them down to the same function calls... then simply change c# syntax to PHP... of course no reason to use PHP to test PHP... I'm sure you could author everything in C# to test a PHP web application.
    kamal2222ahmed
    @kamal2222ahmed
    Thanks @swaibar , the only thing stoping me from using C#, or Java or Python, is that we have a lot of existing code in php in Behat.
    Rikard Hassel
    @rikardhassel
    Is there any recommended file hierarchy when creating multiple contexts, do you just put them under features/bootstrap?
    Rikard Hassel
    @rikardhassel
    Can you even use multiple contexts (by filter) with Behat 2.5?
    swaibar
    @swaibar
    @rikardhassel I just put them in one folder, and they constantly overlap and use each other. As for if you can use them on 2.5, reading https://docs.behat.org/en/latest/cookbooks/accessing_contexts_from_each_other.html states "This is particularly useful when migrating from Behat 2.x to replace subcontexts." So I'm guessing 2.5 would use "subcontexts" instead... best case would be to upgrade and use multiple contexts.
    and "one folder" is "under features/bootstrap"
    Frederico Pinheiro Carvalho
    @fredrelv:matrix.org
    [m]

    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

    Shubham Arora
    @Shubham_2612_twitter
    Hi, can anyone tell me how to click on amazon product or link with php code?
    Any tutorials link to learn Behat using php?
    kashishvashistha
    @kashishvashistha
    Hey...can someone provide me tutorials link for learning behat using php??
    swaibar
    @swaibar
    @kashishvashistha @Shubham_2612_twitter these are the three links (in order of importance) which have taught me all the basics and much more: https://docs.behat.org/en/latest/quick_start.html
    A very large active example code base: https://github.com/Sylius/Sylius/tree/master/features
    Lastly a useful blog on using tables: https://blog.whiteoctober.co.uk/index.html%3Fp=1040.html
    @Shubham_2612_twitter you will need to be using selenium and behat in order to click things (I use behat and guzzle to make HTTP requests 80%, but use selenium for UI stuff too 20%) in order to test my application. If you are asking for this in order to scrap websites, or automatically purchase thing you are most likely violating their terms of service... be prepared for being detected and blocked... if it isn't already made super hard by some sort of obfuscation in key parts.
    hat-diag
    @hat-diag
    I'm using Behat in Laravel and cannot see the exception trace log when a scenario failed in behat, anyone faced this issue before?
    hat-diag
    @hat-diag
    I tried with -v or -vv
    tansiewling-hotmail
    @tansiewling-hotmail
    Hi, I would like to run my behat tests using the Bitbucket pipeline, but I'm not sure how to do it. Do I need some docker environment for the behat tests? I'm not sure what needs to be included in the scripts as well... Can I have some guidance please?
    swaibar
    @swaibar
    @hat-diag or -vvv ? I would ensure application logging captures it or set a breakpoint. I assume you are using Assertions in some cases when I don't see something I create a new Exception, get the trace and put that as the assertaion failure method.
    madman-
    @madman-:matrix.org
    [m]

    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?

    Oh! Never mind, I just thought to go back and re-read the changelog again, and this time I noticed the reference to where 'chained steps' has been pulled out into it's own extension: https://github.com/Behat/ChainedStepsExtension. This looks to be exactly what I want, so I'll just go ahead and give that a go. Thanks for the excellent changelog documentation, I think I've answered my own question :) This package doesn't seem to be in Packagist anymore, but a fork that doesn't change anything from the root repo is, so I'll stick with that. Thanks!
    Robert Smolarczyk
    @RobertSmolarczyk

    Good Morning. Anybody here managed to get behat runnig with selenium grid 4?

    I got this error message: Capability value must be set

    Thanks

    Giedrius Sabaliauskas
    @sabaliauskasg_twitter
    Hello! I wanted to improve our Behat contexts a bit and while working I noticed that 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?
    Andrey
    @Dr10s
    Hello everyone. I have some problem: When i call behat with --format progress parameter, sometimes process end with 139 exit code without any messages about errors. Can someone help me find solution of this problem?
    Anush Karapetyan
    @Anush99
    Hello, has anyone faced a problem with modals? When I click on the button on modal(pop-up) the xhr request stays with pending status and page hangs.