# Assert Functions

<meta charset="UTF-8" id="bkmrk-"></meta><title id="bkmrk-assert-functions---a">Assert Functions - Appvance Test Designer JS Commands</title><style id="bkmrk-body-%7B-font-family%3A-">
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 900px; margin: 0 auto; padding: 20px; line-height: 1.6; }
h1 { color: #1a73e8; border-bottom: 2px solid #1a73e8; padding-bottom: 8px; }
h3 { color: #333; margin-top: 24px; }
code { background: #f0f0f0; padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }
pre { background: #f5f5f5; padding: 12px; border-radius: 4px; overflow-x: auto; }
blockquote { background: #f9f9f9; border-left: 4px solid #1a73e8; margin: 12px 0; padding: 8px 16px; }
p.note { background: #fff3cd; border-left: 4px solid #ffc107; padding: 8px 16px; }
</style></head><body>### \_assertExists = assertExists

Description:   
Asset Exists will log the step in the playback logs when the element exists, it will log as a failure if the element does not exist.  
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

> `navigateTo("`http://demosite.appvance.com/`");`  
> `wait(1000);`  
> `focus(span("Products[1]"));`  
> `assertExists(span("Products[1]"));`

### \_assertNotExists

Parameters: value  
Description:   
Assert Not Exists will log failures in the logs if the element does exist on the page. This assertion is to check if certain elements that we are looking for does not exist on the page.  
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

> `navigateTo("`http://demosite.appvance.com/`");`  
> `wait(1000);`  
> `assertNotExists(span("Products[1]"));`  
> `click(link("Clothing"));`

### \_assertTrue = assertTrue

Parameters: value  
Description: Assert True will log failures in the logs if the condition evaluates to false.  
Example:

> `navigateTo("`http://sahitest.com/demo/training/login.htm`");`  
> `var val2=_isVisible(_bold("Sahi Training Site"));`  
> `assertTrue(val2);`

### \_assertFalse = assertFalse

Parameters: value  
Description:   
Assert False will log failures in the logs if the condition evaluates to true.  
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

> `navigateTo("`http://sahitest.com/demo/training/login.htm`");`  
> `var val1=_getText(_bold("Sahi Training Site"));`  
> `assertDoesNotContainText(log(val1);`  
> `assertEqual(val1,"Sahi Training Site");`  
> `assertNotEqual(val1,"abc");`  
> `assertFalse("abc");`  
> `var val2=_isVisible(_bold("Sahi Training Site"));`  
> `assertTrue(val2);`

### \_assertNull = assertNull

Parameters: value  
Description:  
Assert Null will log failures to the logs if the value is not null and will continue to playback if the value is null.  
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

> `navigateTo("`http://sahitest.com/demo/training/login.htm`");`  
> `assertExists(bold("Sahi Training Site"));`  
> `assertNull(null);`

### \_assertNotNull = assertNotNull

Parameters: value  
Description:   
Assert Not Null will log failure in the logs if the value is null.  
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

> `navigateTo("`http://sahitest.com/demo/training/login.htm`");`  
> `assertExists(bold("Sahi Training Site"));`  
> `assertNotNull("Sahi Training Site");`

### \_assertEqual = assertEqual = \_assertEquals = assertEquals

Parameters: value1, value2  
Description:   
Assert Equal checks if the expected value is equal to the Actual value.  
AssertEqual will log failures to the playback logs if the expected and actual values are not equal. It logs the step when the assertion passes in the logs section.  
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

> `navigateTo("`http://demosite.appvance.com/`");`  
> `click(span("Products[1]"));`  
> `assertEqual(span("Home[1]"),"Home");`  
> `click(link("Clothing"));`

### \_assertNotEqual = assertNotEqual

Parameters: value1, value2  
Description:   
As the name suggests, Assert not equal expects the string to be not equal and logs failures in the playback logs when the Expected string matches with the actual string.  
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

> `navigateTo("`http://demosite.appvance.com/`");`  
> `click(span("Products[1]"));`  
> `assertNotEqual(span("Home[1]"),"Home");`  
> `click(link("Clothing"));`

### \_assertContainsText = assertContainsText

Parameters: fullText, element  
Description:   
As the name suggests, assert contains text checks for a string in the target element and logs success or failure.  
It will log the step details if the assertion passes else it logs as a failure if the expected string or reg-ex is not part of the text content of a given element with a proper explanation and stops the script playback.  
Note: Do not use this in an if condition as it does not return any value, and throws an exception if the assertion fails.

Example:

> `navigateTo("`http://demosite.appvance.com/`");`  
> `click(span("Products[1]"));`  
> `assertContainsText("Home",span("Home[1]"));`  
> `click(link("Clothing"));`

### \_assertDoesNotContainText = assertDoesNotContainText

Parameters: fullText, element  
Description: <span style="color: rgb(0,0,0);">assertContainsText will do nothing if the expected string/regex is not part of the text content of given element \_assertContainsText will log failures to the playback logs if the expected string/regex is part of the text content of given element</span>  
Example:

> `navigateTo("`http://demosite.appvance.com/`");`  
> `click(span("Products[1]"));`  
> `assertDoesNotContainText(click(link("Clothing"));`