Skip to main content

Posts

Showing posts with the label verifyEquals

verifyTrue vs verifyEquals to compare strings

There is a clear winner here! Lets explore which one is better. Here is the scenario: “Lets say I have to test if the appropriate tooltip is flashed for a component” To get to the code directly, lets say I already have the tooltip text stored in a variable. Now all I have to do is to compare this string to the components tooltip text which I would get at runtime. So the algorithm would be Have the Expected Tooltip text stored in a variable Get the Actual Tooltip text for the component Compare the two strings – you should get the exact text We usually tend to use verifyTrue to compare because according to our algorithm we are expecting the result of the string comparison to be TRUE There is nothing wrong in using verifyTrue as if your test passes there is no difference in using verifyTrue or verifyEquals. The actual difference comes into picture only when your test fails. String varExpectedTooltipText = “Some tooltip”; // Method 1 - verifyTrue(selenium.getAttribute(...