Forum Discussion
Dmitry_Nikolaev
15 years agoStaff
Hi Nancy,
First of all, you can just assign the value to the field using its 'Text', 'wText' or another property that contains the values of the text box:
var barcode = "^T)?T8C4NWcPj*8iMC$D*";
var textBox = Aliases.SoftwareName.frmConsumable.z2d223ac_0224_425c_a9b5_8640f2d13173.d9c6e1ea-c1c8-4458-b47e-c82f201c6f52.d9c6e1ea-c1c8-4458-b47e-c82f201c6f52Container.ucBarcodeMultiple.grpBackground.grdBarcodes;
textBox.Text = barcode;
Another way is to prepare code by doubling all the special characters before calling the Keys method. The following script demonstrates this approach:
function Test1()
{
var codes = new Array();
codes.push('^-TSIT/.3OfP7"c]9r2q\\'); // The '\' character should be doubled manually
codes.push('^?lh16-i.mMYp/Mv&J?/%');
codes.push('^Z-Mi+Sv0bjTY/EJUQ#<[');
codes.push('^T)?T8C4NWcPj*8iMC$D*');
for (var i = 0; i < codes.length; i++) {
TestNotepad(prepareBarcodeForKeys(codes));
}
}
function TestNotepad(str)
{
var edit;
edit = Sys.Process("notepad").Window("Notepad", "*").Window("Edit");
edit.Keys(str);
edit.Keys("[Enter]");
}
function prepareBarcodeForKeys(code)
{
code = code.replace(/\^/ig, '^^');
code = code.replace(/\[/ig, '[[');
code = code.replace(/~/ig, '~~');
code = code.replace(/!/ig, '!!');
return code;
}
Please note that you can read code from an external file during your test. Please see the Data-Driven Testing help topic for more information.
Related Content
- 4 years ago
- 9 years ago
- 6 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 6 days ago