Search code examples
androidrubycalabashcalabash-android

Checking if words with an accent was displayed


In automated tests, I need to know how I can check if words with an accent was displayed. I performed automated tests as below:

file.feature

# encoding: utf-8

Feature: Cálculo de triângulo

Scenario: Calculando um triângulo equilátero
    Given que estou na tela do TrianguloApp
    When eu preencher o campo Lado 1 com "3"
        And eu preencher o campo Lado 2 com "3"
        And eu preencher o campo Lado 3 com "3"
        And eu clicar em Calcular
    Then a mensagem "O triângulo é Equilátero" será exibida 

file_steps.rb

Given(/^que estou na tela do TrianguloApp$/) do
    element_exists("* text:'TrianguloApp'")
end

When(/^eu preencher o campo Lado 1 com "(.*?)"$/) do |lado1|
      enter_text "* id:'txtLado1'", "#{lado1}"
end

When(/^eu preencher o campo Lado 2 com "(.*?)"$/) do |lado2|
      enter_text "* id:'txtLado2'", "#{lado2}"
end

When(/^eu preencher o campo Lado 3 com "(.*?)"$/) do |lado3|
      enter_text "* id:'txtLado3'", "#{lado3}"
end

When(/^eu clicar em Calcular$/) do
      touch("* id:'btnCalcular'")
end

Then(/^a mensagem "(.*?)" será exibida$/) do |mensagem|
     element_exists("* O triângulo é Equilátero")
end

The result is as in the image below.

result of the automated test

The error occurred because of trying to verify that the phrase O triângulo é Equilátero was displayed on the screen.


Solution

  • I was able to validate the text O triângulo é Equilátero

    I changed the command element_exists to macro %Q|I should see "#{text}"|

    See how it got:

    Entao(/^a mensagem "(.*?)" será exibida$/) do |mensagem| macro %Q|I should see "#{mensagem}"| end

    Source: http://testmunk.readthedocs.io/en/latest/steps.html