com.github.siwenyan.si.SiEventHandlerAssertEquals Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of side Show documentation
Show all versions of side Show documentation
Java runner of Selenium IDE project
package com.github.siwenyan.si;
import org.junit.Assert;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Map;
import java.util.Properties;
public class SiEventHandlerAssertEquals implements ISiEventHandler {
@Override
public void handle(SiContextMonitorEvent event, Map spec) {
Properties props = new Properties();
props.putAll(spec);
SiContext sc = event.getSiTest().getSiContext();
String s1 = sc.dynamic(props.getProperty("Expected", props.getProperty("Param1")), "", "");
String s2 = sc.dynamic(props.getProperty("Actual", props.getProperty("Param2")), "", "");
sc.getReporter().reportMessage("Comparing [" + s1 + "] with [" + s2 + "]");
String command = props.getProperty("Command");
if ("String".equalsIgnoreCase(command)) {
Assert.assertEquals(s1, s2);
} else if ("Number".equalsIgnoreCase(command)) {
NumberFormat nf = NumberFormat.getInstance();
try {
Assert.assertEquals(nf.parse(s1), nf.parse(s2));
} catch (ParseException e) {
Assert.fail("Invalid number format: [" + s1 + "] VS [" + s2 + "]");
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy