Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda