0

任何人都可以帮我解释这个问题吗?


type(waitForObject(":Address Book - Unnamed.File_QTableWidget"), "");

var Forename = testData.field(record, "Forename");

type(waitForObject(":Address Book - Unnamed.File_QTableWidget"), Forename);


测试数据:名字值是'ABCD'

但它在应用程序中只输入 A,而不是全文。

只输入输入数据的第一个字符的原因可能是什么?

4

2 回答 2

0

“类型”方法一次只输入/考虑一个值。忽略其余的

尝试一次输入一个字母

type(waitForObject(":Address Book - Unnamed.File_QTableWidget"), 'A');
type(waitForObject(":Address Book - Unnamed.File_QTableWidget"), 'B');
type(waitForObject(":Address Book - Unnamed.File_QTableWidget"), 'C');

其他替代品是

nativeType("Hello")

或者

button = findObject("Addressbook.ABCentralWidget1.AddButton")
button.setText("ABCD") 
于 2014-12-18T10:46:32.680 回答
0

类型值参数中指定的完整字符串应输入到 :Address Book - Unnamed.File_QTableWidget 字段中。

:Address Book - Unnamed.File_QTableWidget 有什么特别的吗?它似乎是 Squish 示例 AddressBook AUT 中的一个小部件。

使用 type() 和 testData.field 函数的示例脚本:

function invokeMenuItem(menu, item)
{
    activateItem(waitForObjectItem("{type='QMenuBar' visible='true'}", menu));
    activateItem(waitForObjectItem("{type='QMenu' title='" + menu + "'}", item));
}


function addNameAndAddress(oneNameAndAddress)
{
    invokeMenuItem("Edit", "Add...");
    var fieldNames = new Array("Forename", "Surname", "Email", "Phone");
    for (var i = 0; i < oneNameAndAddress.length; ++i) {
        var fieldName = fieldNames[i];
        var text = oneNameAndAddress[i];
        type(waitForObject(":" + fieldName + ":_QLineEdit"), text);
    }
    clickButton(waitForObject(":Address Book - Add.OK_QPushButton"));
}


function checkNameAndAddress(table, record)
{
    waitForObject(table);
    for (var column = 0; column < testData.fieldNames(record).length; ++column)
        test.compare(table.item(0, column).text(), // New addresses are inserted at the start
                     testData.field(record, column));
}


function closeWithoutSaving()
{
    invokeMenuItem("File", "Quit");
    clickButton(waitForObject(":Address Book.Cancel_QPushButton"));
}


function main()
{
    startApplication("addressbook");
    var table = waitForObject(":Address Book_QTableWidget");
    invokeMenuItem("File", "New");
    test.verify(table.rowCount == 0);
    var limit = 10; // To avoid testing 100s of rows since that would be boring
    var records = testData.dataset("MyAddresses.tsv");
    for (var row = 0; row < records.length; ++row) {
        var record = records[row];
        var forename = testData.field(record, "Forename");
        var surname = testData.field(record, "Surname");
        var email = testData.field(record, "Email");
        var phone = testData.field(record, "Phone");
        table.setCurrentCell(0, 0); // always insert at the start
        addNameAndAddress(new Array(forename, surname, email, phone));
        checkNameAndAddress(table, record);
        if (row > limit)
            break;
    }
    test.verify(table.rowCount == row + 1);
    closeWithoutSaving();
}
于 2015-02-05T03:56:32.773 回答