检查是否显示带重音的单词

时间:2017-10-26 15:33:25

标签: android ruby calabash calabash-android

在自动化测试中,我需要知道如何检查带有重音的单词是否显示。我按如下方式进行了自动化测试:

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

结果如下图所示。

result of the automated test

由于尝试验证屏幕上是否显示短语O triângulo é Equilátero而发生错误。

2 个答案:

答案 0 :(得分:0)

你的陈述缺少文字:

element_exists("* text:'O triângulo é Equilátero'")

这可能就是你需要的所有工作,但是如果你的问题是重音,那么你可以先找到该元素,然后检查文本。

the_text = query("* id:some_id", "text")

expect(the_text).to eql 'O triângulo é Equilátero'

期望来自rspec https://github.com/rspec/rspec-expectations

答案 1 :(得分:0)

我能够验证文字<?php //include("yourCodeBlock.php"); ?>

我将命令O triângulo é Equilátero更改为element_exists

看看它是如何得到的:

macro %Q|I should see "#{text}"|

来源:http://testmunk.readthedocs.io/en/latest/steps.html