小编Tom*_*ski的帖子

使用SuperCSV ICsvBeanReader解析枚举

我解析CSV文件并使用supercsv创建域对象.我的域对象有一个枚举字段,例如:

public class TypeWithEnum {

private Type type;

public TypeWithEnum(Type type) {
    this.type = type;
}

public Type getType() {
    return type;
}

public void setType(Type type) {
    this.type = type;
}
}
Run Code Online (Sandbox Code Playgroud)

我的枚举看起来像这样:

public enum Type {

    CANCEL, REFUND
}
Run Code Online (Sandbox Code Playgroud)

尝试使用此CSV文件创建bean:

final String[] header = new String[]{ "type"  };
ICsvBeanReader inFile = new CsvBeanReader(new FileReader(
    getFilePath(this.getClass(), "learning/enums.csv")), CsvPreference.STANDARD_PREFERENCE);

final CellProcessor[] processors = 
    new CellProcessor[]{ TODO WHAT TO PUT HERE? };
TypeWithEnum myEnum = inFile.read(
    TypeWithEnum.class, header, processors); …
Run Code Online (Sandbox Code Playgroud)

java csv enums supercsv

5
推荐指数
2
解决办法
2635
查看次数

如何改进WebDriver ExpectedCondition的错误消息?

我有一个像这样的实用方法:

public void verifyTitle(int secsToWait) {
    new WebDriverWait(driver, secsToWait)
            .until(ExpectedConditions.titleIs(title));
}
Run Code Online (Sandbox Code Playgroud)

当它失败时,消息是:

org.openqa.selenium.TimeoutException

等待标题后2秒钟超时:此处有一些标题构建信息:版本:'2.2.1',修订版:'16551',时间:'2012-04-11 21:42:35'系统信息:os.名称:'Linux',os.arch:'i386',os.version:'3.0.0-16-generic',java.version:'1.7.0_04'驱动程序信息:driver.version:unknown

我找不到用于提供更好的错误消息的API.我想拥有的是:

等待标题2秒后超时:这里有一些标题(但标题是:其他一些标题)

我可以使用如下所示的try/catch来实现,但也许还有其他选择吗?

public void verifyTitle(int secsToWait) {
    try {
        new WebDriverWait(driver, secsToWait)
                .until(ExpectedConditions.titleIs(title));
    }
    catch (TimeoutException e) {
        throw new AssertionError(String.format("Expected page title [%s] but was [%s]", title, driver.getTitle()));
    }
}
Run Code Online (Sandbox Code Playgroud)

java testing selenium webdriver

2
推荐指数
1
解决办法
2919
查看次数

标签 统计

java ×2

csv ×1

enums ×1

selenium ×1

supercsv ×1

testing ×1

webdriver ×1