problem of keeping behat/selenium browser open after execution

I am attempting to execute the behat/selenium test with Chrome browser by running the following feature scenario. I would like to keep the browser window open instead of closing the Chrome immediately. Even though I have implemented the iWaitForSeconds step definition, I am still encountering errors. Below is the code snippet, can you please assist in identifying what went wrong? Thank you very much!

2 scenarios (2 undefined)
10 steps (8 passed, 2 undefined)
0m3.896s

You can implement step definitions for undefined steps with these snippets:

    /**
     * @Given /^I wait for "([^"]*)" seconds$/
     */
    public function iWaitForSeconds($arg1)
    {
        throw new PendingException();
    }

/behat_sample/features/search.feature

# features/search.feature
Feature: Search
  In order to see a word definition
  As a website user
  I need to be able to search for a word

  @javascript
  Scenario: Searching for a page that does exist
    Given I am on "/wiki/Main_Page"
    When I fill in "search" with "Behavior Driven Development"
    And I press "searchButton"
    Then I should see "agile software development"
    And I wait for "60" seconds

/behat_sample/behat.yml

#behat.yml
default:
  paths:
    features: features
    bootstrap: '/behat_sample/features/bootstrap'
  extensions:
    Behat\MinkExtension\Extension:
      base_url: 'http://en.wikipedia.org/'
      goutte: ~
      selenium2: ~
      browser_name: chrome

/behat_sample/features/bootstrap/FeatureContext.php

namespace bootstrap;
    use Behat\Behat\Context\ClosuredContextInterface,
        Behat\Behat\Context\TranslatedContextInterface,
        Behat\Behat\Context\BehatContext,
        Behat\Behat\Exception\PendingException;
    use Behat\Gherkin\Node\PyStringNode,
        Behat\Gherkin\Node\TableNode;
    use Behat\MinkExtension\Context\MinkContext;

    /**
    * Features context.
    */
    class FeatureContext extends MinkContext
    {
    /**
    * Initializes context.
    * Every scenario gets it's own context object.
    *
    * @param array $parameters context parameters (set them up through behat.yml)
    */
    public function __construct(array $parameters)
    {
        // Initialize your context here

    }
    /**
    * @Given /^I wait for (\d+) seconds$/
    */
    public function iWaitForSeconds($seconds)
    {
         $this->getSession()->wait($seconds*1000);
         throw new PendingException();
    }

Answer №1

It appears that the path set in the bootstrap configuration key is incorrect. Instead of looking for /behat_sample/features/bootstrap, it should be searching for

your_current_base_behat_dir/features/bootstrap
.

To resolve this issue, you can try the following:

bootstrap: '%paths.base%/features/bootstrap'
where %paths.base% represents the root directory of Behat from where you initiate the execution.

Answer №2

Upon reviewing the code, it appears that the throw new PendingException() in the step implementation of /^I wait for (\d+) seconds$/ should be removed.

Once the waiting period is completed, the code should proceed without any exceptions being thrown.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Three.js - Rotation does not follow local orientation accurately

In my current project, I have created an extensive array of objects centered around a focal point within a scene. My goal is to manipulate these objects along their local axes. Initially, I aligned all the objects to face the origin by using a reference ob ...

Extracting online information with the help of PhantomJS and Selenium

Utilizing Phantomjs with Selenium to extract data from the provided link in the code snippet. When extracting the data using element.text in phantomjs (web element), I am encountering some empty values, whereas with chromedriver I was able to extract all d ...

Locate the element by hovering the mouse in Python Selenium to select it

Hello, I am currently working on a script and encountering difficulties in locating an element. I am using CSS selectors and XPaths to find the element, but it seems that there is an iframe blocking my access. Please refer to the image at this link: https: ...

In the n-th click event, the key press button is fired n times

I am working on developing a game that includes a start button. Once this button is clicked, the game will begin and involves various keyboard key press events. The issue arises when the start button is clicked multiple times causing the game to run repeat ...

A variety of menu items are featured, each one uniquely colored

In the user interface I developed, users have the ability to specify the number of floors in their building. Each menu item in the system corresponds to a floor. While this setup is functional, I am looking to give each menu item a unique background color ...

Regular Expressions for Strings in JavaScript

I want to create a regular expression in JavaScript that can search for patterns like ${.............}. For example, if I have a string like { "type" : "id", "id" : ${idOf('/tar/check/inof/high1')}, "details" : [ { ...

Safari is capable of rendering Jquery, whereas Chrome seems to have trouble

The code I am using renders perfectly in Safari but not in Chrome. Despite checking the console in Chrome, no errors are showing up. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="ht ...

granting authorization to modify content post channel establishment in discord using discord.js

I am encountering an issue with granting the message.author and staff permission to view the channel right after its creation. The problem arises when the channel's parent (category) is changed, causing it to synchronize with the permissions of the pa ...

What is the process of including a pre-existing product as nested attributes in Rails invoices?

I've been researching nested attributes in Rails, and I came across a gem called cocoon that seems to meet my needs for distributing forms with nested attributes. It provides all the necessary implementation so far. However, I want to explore adding e ...

"Explore the versatility of React Day Picker with customizable months and weekdays_long

I have implemented the following packages: "react": "^18.2.0", "react-day-picker": "^8.1.0", and I am attempting to translate the months and days into French. However, despite passing the translated arrays to my < ...

Issue with form array patching causing value not to be set on material multiple select

When attempting to populate a mat-select with multiple options using an array of ids from Firestore, I encountered an issue. The approach involved looping through the array, creating a new form control for each id, and then adding it to the formArray using ...

Access a webpage using a Python web-scraping tool to log in

Currently, I am employing Selenium WebDriver within Python to carry out a web scraping endeavor. My aim is to log in by inputting the necessary login credentials and subsequently clicking on the submit button. Although successful in entering the Username ...

What steps can be taken to enable users to draw a path on a Google Map?

I'm working on a new project for a Facebook app that will allow users to map out their marathon route using Google Maps. I plan to utilize mySQL database records to store fixed points along the path (such as specific locations based on latitude and lo ...

When using the e.target.getAttribute() method in React, custom attributes may not be successfully retrieved

I am struggling with handling custom attributes in my changeHandler function. Unfortunately, React does not seem to acknowledge the custom "data-index" attribute. All other standard attributes (such as name, label, etc.) work fine. What could be the issu ...

Developing dynamic forms within arrays using AngularJS

Hey there! I've got a scenario where I have an array of people in my dynamic application. Each person, such as James, Bob, and Walter, has their own set of data that needs to be filled out using simple directives. $scope.users = [ { name: ...

Launching the webpage with Next.js version 13

Hey there! I'm currently working on implementing a loading screen for my website to enhance the user experience. Since it's quite a large site, I believe a loading screen would be beneficial. However, I'm having trouble getting it to work on ...

The `chrome.windows` API is not defined for this particular Chrome

I'm currently in the process of developing a Chrome extension that will allow users to effectively manage open tabs within a specific application's website. Here is the current manifest file: { "manifest_version": 2, "name": "AT Tabs", ...

The second pop-up modal fails to appear

I have successfully implemented 2 modal windows with the help of bootstrap. The first modal is used for adding a user to the database, and the second one is meant for editing an existing user. While the first modal works perfectly fine, the editing modal d ...

Determining outcomes of forms added in real-time

Need assistance with dynamically creating tickets, calculating prices, and displaying results when additional tickets are added. Currently facing an issue where price data is not being calculated when a new ticket is added. Any help would be greatly apprec ...

Tips for accurately dissecting a PDF document to determine the status of checkboxes

Looking for a solution to parse PDF forms on the server side, I have experimented with various node.js modules including pdf2json, hummus, and node-pdftk. While I have successfully retrieved all text fields, I am facing issues when it comes to extracting c ...