Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

236
Vistas
Using Javascript Cucumberjs is it possible to call a function from Scenario outline?

I have a framework that I am building from the ground up using webdriver-IO cucumber and javascript. I have a drop down control to select from and I can only select the option based on 'text()='

I am trying to include a function call in my Scenario Outline and include this in the inline table

Please let me know if this is possible?

Scenario Outline: Generate a standard quote
    Given I am a potential client 
    When I enter <age> <income> <smoker> <education> <gender> AND I perform the action Calculate          
    Then I am presented with a quote
   

  Examples:
|  age  | income| smoker           | education           | gender              |
| 22    | 30000 | ddlText.NoSmoker | ddlText.edu3YearDip | ddlText.genderMale  | 
| 22    | 30000 | ddlText.YesSmoker| ddlText.edu4YearDip | ddlText.genderFemale|

I have a getter class and the reason for this approach is because controls do not have ids, its not a k/v pair and I can only find the text when selecting from a drop down list. So note above in the inline table I am trying to call ddlText.NoSmoker and my implementation will then make the selection based on the value from the inline table

class ddlText{
    get NoSmoker(){
        return $("//*[text()='No']")
    }

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Trying to program in gherkin is a really bad idea. Gherkin is not a programming language its a limited natural language designed to express intention. So trying to put things like function calls in Gherkin is only going to cause you pain.

Secondly avoid scenario outlines. Its much better to write a few simple scenarios than one complex scenario outline. The art of using Cucumber is to keep your features as simple as possible. Push your complexity down to the step definitions or better still helper methods or your application code.

So instead of doing one scenario outline for generating quotes. Do several scenarios, one for each type of quote.

Scenario: Smoker quote
  Given I am a smoker
  When I enter my details
  Then I should get a quote

Scenario: Non smoker quote
  Given I am a non smoker
  When I enter my details
  Then I should get a quote

Then use the step definitions to determine how to use your select control.

When "I enter my details" do
  ...
  @i.smoker? ? select smoker : select non_smoker
  ...
end

Because your step definitions are in a programming language you can do clever things like

  • use method calls
  • create objects to represent things your feature needs

@i is a person.object created in the Given who has a method smoker?

Now your features are simple, and your complexity is all in the code where you have the power to do whatever you want.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda