automation - How to put asserts in Selenium webdriver Ruby script? -


I want to check the value on the UI with the value given in the script. And when comparing these two, it should display the message "Passed the test" in the console.

I have written the following code: -

  browser.find_lement (: xpath, "/ / * [@ id =" total "] / tbody / tr / Td [4] / span "). Value.should ==" $ 466,634,599.67 " 

But it does not display anything console What may be needed next?

Thank you! Abhishek

rendering, such as . Should == , it is usually used as a testing frame in the form of RSPC, Mintest, Cucumber, etc. These test structures are designed to be claimed near or to report a failed outcome.

Given that you are not using a test framework, you manually handle the results of the results.

The easiest way to leave the assurance part and if the statement must be used:

  element_value = Text.string_element == "$ 466,634,599.67 "puts 'test passed' and 'test' fails 'end' end  

Note that puts are used for output results in the Statement Console (Unless you have changed the default output location).

Alternatively, if you want to use the confirmation, you can:

  element_value = browser.find_element (: xpath, "// tester_trade_text_target /transpace/states_template/value.should== "$ 466,634,599.67" puts 'test passed'  

In this approach, if the test fails, the claim will take an exception. This assertion code And therefore 'test passed' will not produce the message (expected). If the exam is passed, then The 'test pass' message will be output.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -