type

Class: matlab.uitest.TestCase
Package: matlab.uitest

Type in UI component

Syntax

type(testcase,comp,value)

Description

type(testcase,comp,value) types value in the UI component comp.

Input Arguments

expand all

Instance of the test case, specified as a matlab.uitest.TestCase object.

Component to type in during test, specified as a UI component object that supports a type gesture. Components that support type gestures include edit fields and text areas.

Supported ComponentTypical Creation Function
Date Pickeruidatepicker
Drop Downuidropdown
Edit Field (Numeric, Text)uieditfield
Spinneruispinner
Text Areauitextarea

Value to type into the component. The data type of value depends on the type of component under test. For example, if comp is a spinner, value is specified as a numeric. If comp is a text area, value is specified as a character vector or string.

Examples

expand all

Create a text edit field.

ed = uieditfield('Value','Hello')

Create an interactive test case and verify the initial value.

tc = matlab.uitest.TestCase.forInteractiveUse;
tc.verifyEqual(ed.Value,'Hello')
Verification passed.

Type the word "Goodbye" in the edit field and verify the new value.

value = 'Goodbye';
tc.type(ed,value)
tc.verifyEqual(ed.Value,value)
Verification passed.

Create an editable drop-down list.

dropdown = uidropdown('Editable','on');

Create an interactive test case and add a custom item to the drop-down list.

tc = matlab.uitest.TestCase.forInteractiveUse;
tc.type(dropdown,'Custom Item')

Verify the new value.

tc.verifyEqual(dropdown.Value,'Custom Item')
Verification passed.
Introduced in R2018a