Selenium WebDriver - Ruby Assert声明

时间:2016-11-07 15:01:31

标签: ruby selenium selenium-webdriver

抱歉显而易见的Noob问题。我正在尝试确认页面上有一段文字。

HTML:

<div id="fmForm">
<a name="Contact"/>
<p class="errormsg">
Please provide a little more information about your enquiry  
<br/>
</p>

我正在使用以下断言语句

Then(/^The website should show the following error message "([^"]*)"$/) do |website_error|
  SuccessMessage = driver.find_element(:class,"errormsg")
  website_error.eql? SuccessMessage.text
end

从以下步骤开始:

Then The website should show the following error message "Please provide a little more information about your enquiry"

当我跑这个时,它就过去了。如果我将步骤更改为:

Then The website should show the following error message "Please provide a little more information about your enquiry00000"

它也过去了。我在这里错过了什么吗?我似乎找不到ASSERT EXACT Text

1 个答案:

答案 0 :(得分:0)

然后(/ ^网站应显示以下错误消息&#34;([^&#34;] *)&#34; $ /)do | website_error |   SuccessMessage = driver.find_element(:class,&#34; errormsg&#34;)

  

expect(website_error).to eq(SuccessMessage.text)