Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Christian Bolduc
    @snowfrogblues
    @Jeemo_gitlab - It worked for me with the quotes. Hope it works for you. Cheers
    Jee Elmore
    @Jeemo_gitlab
    @snowfrogblues Awesome!
    Guillaume R
    @rikemSen
    Hey there :)
    I made my company use behat for a large ecommerce platform :D However, I'm still new to it and I am wondering how would I write / organize my scenario for a specific feature : the search
    We set "nodes". A node is a "node" which contains a product category and some filters for search bounded to it.
    Do you have some examples for a search scenario? I mean just typing "Given I want to search for a product" - "When I enter <keyword>" - "Then the results must contain ...."
    Seems relatively light
    abhi2950
    @abhi2950
    Hi All
    Error: Call to a member function source() on null in Behat\Mink\Driver\Selenium2Driver->getContent() (line 487 of /mnt/gfs/home/utcfs/behat/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php)
    getting this error on Behat when executing test cases on Drupal 7
    Jee Elmore
    @Jeemo_gitlab
    @rikemSen Have you followed any tutorials for behat scenario writing?
    @abhi2950 Do you have selenium running in the background?
    Bit Wombat
    @bitwombat
    What have I done wrong if behat just dumps the context steps to STDIO rather than a php file?
    Bit Wombat
    @bitwombat
    I see the ContextSnippetAppender but can't see why it wouldn't be invoked.
    Bit Wombat
    @bitwombat
    Oh, der, --append-snippets
    Pretty sure this used to be the default?
    Anyway, I wish the chat were more alive! Love behat. Used it extensively in my last project (2 years ago).
    George2023
    @George2023
    Hi guys
    is that possible to make
    Bhat test for prestashop for example add products for load test ?
    Karolis Stanelis
    @k.stanelis_gitlab

    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

    swaibar
    @swaibar
    @George2023
    sure, setup a test system, use facebook webdriver and selenium and write some features. You could also use guzzle and directly make http calls if you prefer.
    @rikemSen great to hear you are using this... maybe https://github.com/Sylius/Sylius/tree/master/features might be of some general help... but specifically about your search question... I don't see why it's "too light"... I mean you might have a single scenario like that... or you might use a scenario outline to have many examples with the same steps but different input/output expected
    Chris Burgess
    @xurizaemon_gitlab
    Anyone able to comment on Behat + Sauce + Gitlab CI? (in particular interested if Sauce has a driver that can be executed from within CI containers to "browse" a site)
    mostly I use behat + chromedriver in Gitlab CI and it works a treat, but we've a requirement to automate cross-browser too
    DyanZhao
    @DyanZhao
    Hello
    WeeDom
    @WeeDom

    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

    tansiewling-hotmail
    @tansiewling-hotmail
    Hi! I'm working on a sign in flow for my organisation's website. the sign in form shows in a modal pop up.
    Once I opened up the sign in form, I tried the step in mink context: When I fill in "email" with "bwayne@email.com", then I get the error that the element is not reachable by keyboard.
    Can help to advise me is there something I'm doing wrongly?
    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.