assertElementPresent, verifyElementPresent - Selenium IDE
assertElementPresent (target, pattern) , verifyElementPresent (locator, text)- Selenium IDE command
assertElementPresent and verifyElementPresent check that the element - as defined by the locator exists.
In the Kantu IDE assertElementPresent is technically like a Click command with the click, it just checks if element is present. This means it also does implicit waiting like CLICK command, so it waits !timeout_wait for the element to appear. In the old IDE you would need to combine WaitForElementPresent + assertElementPresent, here it is only assertElementPresent.
Assert and verify commands are both useful for verifying condition match or not. The difference is that verify command will verify the condition and if it does not match, it will only show an error message in log area and the macro continues to run. With the assert command, if the condition does not match then it will stop remaining macro execution in the selenium IDE software testing tools.
User question: I am needing to run a command that detects if a element is present. If it is present, it can jump to a label, if it is not present, it can jump to a different label or simple keep running the next commands. Please let me know if this is possible. I understand that verifyElementPresent will return the results in the console, but how can I use that information to determine the next action to take. Solution: The internal variable !LastCommandOK has the status of each executed command. Use it together with if/else or GotoIf. The good thing about the verify... commands is that the execution continues even if an error is logged. With other commands, you can add a store | true | !errorignore to achieve the same. The screenshot shows the solution:
assertElementPresent and verifyElementPresent Example
In this short example, we check for the presence of two DOM elements. If "Welcome" is missing, the macro stops since we used assert.
Related Demo Macros
DemoStoreEval uses many Asserts
The ready-to-import-and-run source code of all demo macros can be found in the Github repository testmacros folder.
Anything wrong or missing on this page? Suggestions?
...then please contact us.