Assertions, eg the .should==
, are typically used within a test framework such as RSpec, MiniTest, Cucumber, etc. These test frameworks are designed to have reporting of the assertion's pass or fail result.
Given that you are not using a test framework, you will need to manually handle the output of results.
The most straightforward way would be to drop the assertion part and use an if
statement:
element_value = browser.find_element(:xpath,"//*[@id="total"]/tbody/tr/td[4]/span").text
if element_value == "$466,634,599.67"
puts 'Test passed'
else
puts 'Test failed'
end
Note that the puts
statements are used to output results to the console (unless you have changed the default output location).
Alternatively, if you do want to use the assertion, you could do:
element_value = browser.find_element(:xpath,"//*[@id="total"]/tbody/tr/td[4]/span").text
element_value.should == "$466,634,599.67"
puts 'Test passed'
In this approach, the assertion will raise an exception if the test fails. The assertion would stop the execution of the code and would therefore not output the 'Test passed' message (as expected). If the test passes, the 'Test passed' message would get outputted.