Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ghost
    @ghost~54b7c3b4db8155e6700eb40b
    Hi all
    Is there any way with Behat 3.5 to store failed tests result in a file to be able to rerun it after ?
    John Behrens
    @WebconsultsEu_gitlab
    Hi there, wonder if somebody is here who could help me.
    I got a problem with object(Behat\Mink\Element\DocumentElement)#1743 (4)
    even the esaiest css or xpath selector with $page->find() is returning null
    no idea where to look further
    John Behrens
    @WebconsultsEu_gitlab
    i guess nobody is here
    PurHur
    @PurHur
    This channel is not very active you have to wait a little bit :)
    But sounds like the browser is not responding or has a white screen
    John Behrens
    @WebconsultsEu_gitlab
    Code
    public function iShouldSeeGithublogin()
        {
            $session = $this->getSession();        
            $session->start();
            $session->visit('https://github.com/login');
            $page = $session->getPage();
            //var_dump($this->getSession()->getPage());
            $pageContent = $this->getSession()->getPage()->getContent();
            $titleStart = strpos($pageContent, "<title");
            $titleEnd = strpos($pageContent, "</title");
            if(null === $titleStart || null === $titleEnd) {
                throw new \Exception('title not found by strpos');
            } else {
                echo "\n TitleStart:".$titleStart." TitleEnd:".$titleEnd."\n";
            }
    
            $title = $page->find('css', 'title');
            if (null === $title) {
               throw new \Exception('Couldn\'t locate the title.');
            }
        }
    @javascript
    Scenario: Show the Login Screen # features/githublogin/githublogin.feature:4
    Given I visit the GitbubLogin Page # GithubLoginFeatureContext::iVisitTheGitbubloginPage()
    When I see the GithubLoginPage # GithubLoginFeatureContext::iSeeTheGithubloginpage()
    Then I should see GithubLogin # GithubLoginFeatureContext::iShouldSeeGithublogin()

    │ TitleStart:1471 TitleEnd:1505

    Couldn't locate the title. (Exception)
    seems like $page->find is never working however whyt i try
    PurHur
    @PurHur
    Try to make a screenshot. It sounds like the browser isnt respoonding properly
    John Behrens
    @WebconsultsEu_gitlab
    if i use selenium browser is opening the page, and the pageContent is the correct content of the page
    Tadas Davidsonas
    @tdavidsonas88
    Hi there, is there a nice way to use phpunit assertions inside Behat? Pros / cons for doing that? I find using phpunit within Behat context a bit more productive. Just the way to include the library from vendors folder does not seem nice.
    require_once DIR . '/../../../../../../vendor/phpunit/phpunit/src/Framework/Assert/Functions.php'; does not seem nice or the other way I have to do it with 'use' in every class.
    Tadas Davidsonas
    @tdavidsonas88
    so in general not sure if it is a good idea using phpunit assertions inside Behat contexts
    kevin-schmitt
    @kevin-schmitt
    Hello everyone, i have a question can you help me please? I have to work project with multiple rest api and i want use behat for testing. But for best practice and best evolution It's more efficient to use one behat/composer.json/context for test all api with different base_url like explain here Behat/MinkExtension#155 or just init behat test for each repo with one configuration by project. Thanks
    kevin-schmitt
    @kevin-schmitt
    I decided to use behat in each project for avoid to switch each time i want read or write test for one repo, and in the futur for easy apply bdd without to need switch between 2 projects :)
    Richard Hagen
    @Richard87

    Hi everyone! I'm new to Behat, and trying to test a few custom API-platform endpoints...
    How can I get the ID from the form with the name Global formfor usage later in the scenario?

      Scenario: Create answerset to a public form
        Given There is a public Form with name "Global form"
        When I request "GET /api/answer_sets/find?form=14"

    Or is there a different prefered way of handling it?

    Richard Hagen
    @Richard87
    Twig to the rescue... Would love to hear about it if there is a better way ;)
        /**
         * @When I request :arg1
         */
        public function iRequest($arg1): void
        {
            [$method, $path] = explode(" ", $arg1);
    
            $template = $this->environment->createTemplate($path);
            $path = $template->render([
                'givenUser' => $this->givenUser,
                'givenForm' => $this->givenForm,
            ]);
    
            $request = Request::create($path, $method,[],[],[],[],$this->content);
            foreach ($this->headers as $key => $value)
                $request->headers->set($key, $value);
    
            $this->response = $this->kernel->handle($request);
    
            $this->content = $this->response->getContent();
            $this->json = json_decode($this->content,true);
        }
    PurHur
    @PurHur
    Is $path a real url? Do you use twig to generate urls?
    the correct thing todo would be first requesting your page and then looking onto it like that:
    When I request "GET /api/answer_sets/find?form=14"
    Then There is a public Form with name "Global form"
    a computer doesnt look backwarts normaly
    Richard Hagen
    @Richard87

    Hi, no the id is dynamic and can't be guessed, In production the id is "well known" and hard coded in distributed links, but in testing we generate the new forms dynamically, so we can't guess the ID it will receive, except for maybe logging in as admin and picking the form from the list...

    The problem is getting or creating the answerSet for a given form, since I can't guess the id (storing the givenForm etc, and using twig to generate it works!)
    but I have a new challenge :D

    How can I verify that 2 consecutive calls to the same path returns the same answerSet (the id is identical)?

    Michael Gerdemann
    @gerdemann
    Hello everybody,
    is there anyone here who can release a new version of behat/transliterator?
    Behat/Transliterator#25
    @stof or @everzet? :-)
    PurHur
    @PurHur
    Its very quiet around the old behat maintainers. The best thing you can do is to advertise for more development, get the maintainership and do it on your own.
    Michael Gerdemann
    @gerdemann
    Yeah, I know... In this case, not even anything needs to be programmed. It takes only 3 clicks on Github to create a new release.
    PurHur
    @PurHur
    Yes its really sad. We have to buildup the community again. Probably its a good idea to spam here if the old maintainer is still online
    but this community isnt really active at all
    Michael Gerdemann
    @gerdemann
    I just thought I would write it here again, hoping that the old maintainers would read it somewhere
    Jeff Martin
    @RunCrywolf
    Hey guys, I know pantheon released an article on using Behat for unit testing on js environnement, would you say it can also be used for suiteCommerce which is also made in JS? Let me know, there could be a lot of potential! Thanks 🙏
    pcfreak
    @pcfreak
    Hi
    I keep getting an error that my " context class not found and can not be used."
    its not autoloading probably even though it's in the bootstrap directory
    I'm declaring the path in the .yml file as well
    pcfreak
    @pcfreak
    ok I'm past that stage
    Even André Fiskvik
    @grEvenX
    Hi all! Anyone managed a service with many automated behat feature definitions? Currently we have approached it with one FeatureContext and a bunch of traits, but the whole thing becomes unmanageable and hard to reason about. I wondered if there was anyone with previous experiences in this case or if there were some good examples for bigger open source repositories that has a good way of structuring it.
    PurHur
    @PurHur
    If you come back grEvenX" You can use as many FeatureContext Classes as you like. Probably that is what you have done with the traits
    just list them in the behat.yml
    Even André Fiskvik
    @grEvenX
    yes, I'm aware you can have several. But I'm still struggling with how to organize it in a way that makes sense. Would have been nice to see some good examples
    PurHur
    @PurHur
    I cant show you my test repos but there are "generic" FeatureContexts and then a ApplicationFeatureContext and mostly a MailContext
    how many do you have?
    Even André Fiskvik
    @grEvenX
    I currently have a huge FeatureContext split into "feature" by trait. Now I'm trying to see if it should be a FeatureContext "per feature group" instead
    PurHur
    @PurHur
    I dont try not to write to many specific sentences and stick to the basic concepts of mink or json testing and write the tests not very "customized". I dont have a sentence for each test.
    That is more on the behaviour side of the user. Since else you could skip an important step of the behaviour driven testing if everything is written in code.
    Even André Fiskvik
    @grEvenX
    So you write more low-level scenarios compared to high-level scenarios?
    more closely to the UI itself, rather than the overall business requirements
    PurHur
    @PurHur
    yes