簡體   English   中英

獲取帶有索引號的文本,然后與期望的文本進行比較

[英]get text with index number and then compare with the expected text

我需要編寫一種方法,該方法將從彈出窗口中借助索引號獲取文本,然后需要與預期文本進行比較,即我需要驗證預期計划名稱是否顯示在彈出框的底部

彈出框的快照

在下面的代碼上設置正確的查詢ID(可以通過在calabash控制台上執行命令query("*", :id) )應該可以解決問題。 如果無法使用id,請嘗試獲取另一個組件屬性(例如,通過使用query("*")來獲取Android組件),然后在get_text調用中設置查詢。

def get_text(query)
  query(plan_query, :text).first
end

def text_equals(text, expected_text)
  unless text == expected_text
    fail "#{text} not equal to #{expected_text}"
  end
end

def verify_plan(index, expected_text)
  plan_text = get_text("* id:'PLAN_TEXTS_ID' index:#{index}") # Can change 'id:...'' by Android class if plan does not have id
  expected_text = get_text("* id:'BOTTOM_PLAN_ID'") # Same as above
  text_equals(plan_text, expected_text)
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM