1

执行 FitNesse 脚本时,出现“实例 scriptTableActor。不存在”错误。任何人都可以解释这个错误的含义吗?

我在 eclipse 中创建了一个夹具:

/**
 * To enter text or numbers in a text field, add this row to your FitNesse script table:
 * <html> <br/> <br/>
 *    | Enter value xpath | value | in field |fieldXpath |
 *    <br/> <br/>
 * </html>
 * tags: setter
 * @param fieldXpath the field xpath assigned to the target field
 * @param input the characters to be entered
 * @return true if text entered successfully
 */
public boolean EnterValueInFieldByXpath(String xpath, String value) {
    try {
        println "in the EnterValueInFieldByXpath method "
        WebElement e = driver.findElement(By.xpath(xpath))
        e.clear()
        e.sendKeys(value)
        return true
    } catch (Exception e) {
        println "apparently did not find the $xpath Link: ${e}"
        return false
    }

}

当我在 FitNesse 命令中使用这个夹具时,就会出现这样的错误。

请指导。

4

1 回答 1

2

好吧,这里有两件事值得注意。首先是我假设您确实在尝试将其用作脚本表的一部分。为此,脚本表行不能是独立的。所以你需要一个脚本行。如果您打算使用决策表,这不是这样做的方法。请参阅:http: //fitnesse.org/FitNesse.UserGuide.SliM.DecisionTable

其次,我很确定您的行与方法的签名不匹配。我认为应该是:

/**
 * To enter text or numbers in a text field, add this row to your FitNesse script table:
 * <html> <br/> <br/>
 *    | Enter value | value | in field |field| by xpath |
 *    <br/> <br/>
 * </html>
 * tags: setter
 * @param fieldXpath the field xpath assigned to the target field
 * @param input the characters to be entered
 * @return true if text entered successfully
 */
public boolean EnterValueInFieldByXpath( String value, String xpath) {
    try {
        println "in the EnterValueInFieldByXpath method "
        WebElement e = driver.findElement(By.xpath(xpath))
        e.clear()
        e.sendKeys(value)
        return true
    } catch (Exception e) {
        println "apparently did not find the $xpath Link: ${e}"
        return false
    }

}

方法名称中的所有单词在表使用中都是必需的。您在示例区域中遗漏了一些内容。

最后,你的论点被推翻了。值应该在 xpath 之前,而不是相反。

于 2013-03-06T14:31:25.483 回答