Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Adrien Cantepie
    @acantepie
    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

    3 replies
    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.
    Victor Efimov
    @vicefi_gitlab

    Hello there!
    Is it possible to use FeatureContext->kernel in my API requests?

    The problem is that I override the service method by mock in FeatureContext->kernel->container and then in request this service is not mocked.

    is there any solution to solve this issue?

    Alexandre Lemaire
    @Saeven
    Anyone aware of a means to capture 'coverage' while a suite of Behat tests is running? I was wondering if I could use Behat as an extra set of eyes for controller/action coverage.
    Mohit jangra
    @mohit_jangra:matrix.org
    [m]
    Anyone help me out for the error
    everything is okay but after launching browser web address not working
    cparry42
    @cparry42
    Hello - I'm just getting started with behat 3.8.1 and running into the "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!
    cparry42
    @cparry42
    Hi folks - can anyone advise on how to use PHPUnit with Behat? I have tried calling PHPUnit tests from Behat FeatureContext file as a command line exec() but that seems like more of a manual process than should be required. If there is a way to move closely integrate these two tools, it would excellent - thank you!
    kevin
    @zazanor_gitlab
    Why use phpunit ? I juste use Assertion
    on contexte https://packagist.org/packages/webmozart/assert
    alfonsoFortinbrass
    @alfonsoFortinbrass
    Hi All, I am running some behat/mink tests, testing google pay.
    -> i login to a google account
    -> i go to our payment form and press pay.
    -> gpay new window appears and all i have to do is press pay.
    -> But i can not set focus on the new window.
    -> Can i run a native selenium call from behat to do something like
    new Actions(driver).moveToElement(element).moveByOffset(dx, dy).click().perform();
    pdharmendra2005
    @pdharmendra2005
    Hello, Where can I find video tutorial for Behat Framework in PHPStorm?? Thanks
    Weblighten LLC
    @weblighten_gitlab

    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.

    Malik Awais
    @OvaizM_twitter
    Hello, is there any guide to upgrade from 2.5 to 3.10 ?
    Nick van der Zwet
    @nickvanderzwet
    Hello, I'm trying to test some endpoint in Api-Platform (json responses). It seems like https://packagist.org/packages/behat/web-api-extension isn't supported anymore, is there an alternative? Behatch has some contexts for json and api's but I don't understand how a can extend those existing contexts.
    Nick van der Zwet
    @nickvanderzwet
    I think i can manage it with behatch json only
    Screaming Dev
    @ScreamingDev_twitter
    Hello there. Can I make a behat feature require another feature file before somehow? Perhaps there is already a thing for this or someone can give me a hint how to implement this in the own FeatureContext
    require means not to add the steps to the current feature file. sorry. I meant depend on another feature. So that feature A runs after feature X.
    chulhee yoon
    @cyoon84_twitter
    Hello I have a problem with drupal/drush with this step - Given I am logged in as a user with the "authenticated" role
    2 replies
    the test doesnt start with this error message - Unable to determine if logged in because 'log_out' link cannot be found for user 'aUNetb6i' with role 'authenticated' (Exception)
    Guilherme Pagliarini
    @paguii:matrix.org
    [m]
    Hello Guys, I work in a project where we have lots of behat tests, about 2000. We are experiencing problems with CI/CD because to run the tests are taking too much or it fails because the AWS machine starts to lose performance. Do you guys have any suggestions about optimizing ours tests? Not only getting a better machine in AWS but optimizing our tests to make it scalable.
    Farah
    @farah0808
    Hi everybody! I've literally been working on this task for a few weeks. I've been trying to install and use the Drupal Behat_UI module with Drupal 9.4.3, Acquia and Composer. I know Acquia Pipelines isn't compatible with Selenium so I've been trying to install PhantomJS to use an alternative but just getting the same results, of it not working. Has anyone successfully been able to use this module?
    Salva Maine
    @salvamaine_twitter
    Hi! Is there a phar file for a version compatible with PHP5.6?
    ArunPzd
    @ArunPzd
    Hi all, Is there a way to automate 2FA in Behat
    swaibar
    @swaibar
    Hi all, Is there a way to automate 2FA in Behat
    If you can control the "2nd factor" then yes... e.g. can you use a second email? a SMS inbound to email service? you could even use a desktop app like authy and automated that with auto-hot-key