These are chat archives for Behat/Behat

Mar 2017
Mar 10 2017 13:35

Hey there, I'm having troubles understanding how behat executes the steps. Here's my problem. I have roughly 2 steps, one publishing a content to the front page and a second one parsing the front page HTML to verify that the content is published on the front page.

The scenarion looks like this:

  Scenario Outline: Test blog "Promu en page d'accueil"
    Given the blog "<name>" gets promoted on the frontpage
    When I am on the homepage
    Then the blog "<name>" should be promoted on the frontpage

      | name         |
      | BLOG-3-BEHAT |

Step 1:

// Function called by "Given the blog "<name>" gets promoted on the frontpage"
  private function _node_set_promote($nid, $promote = TRUE) {
    $node = node_load($nid);
    if ($promote === TRUE) {
      $node->promote = '1';
    else {
      $node->promote = '0';
    return $node;

Step 2:

  public function theBlogShouldBePromotedOnTheFrontpage($arg1) {
    $selector = 'div.pane-views-view-blog-accueil-blog h1.field-content';

    $session = $this->getSession();
    $page = $session->getPage();
    $element = $page->find('css', $selector);
    if ($element != NULL) {
    else {
      throw new Exception();

The problem is that if I look at the HTML with:


The content is just not there

However, when my test is over and failed, if I myself check my website, the content now appears on the front page
I can also avoid the problem by removing the first step from my test and promoting the content on the front page from BeforeFeature instead, and then step 2 will work just fine
But that's not what I wanna achieve
Mar 10 2017 15:01
With more testing, it seems that the problem is related to scenarios
I just can't find a way to publish the node either by using a step in my scenario or by using BeforeScenario
I tried Background too, no success
So far, only BeforeFeature and BeforeSuite worked
Mar 10 2017 15:17
Okay nevermind, I found the problem and it was on drupal side.
node->promote = 1;
node_save($node); // This automatically sets node->status to 0
Sorry about the wall of text :<