我使用 Selenium IDE 创建了一个记录测试,使用的命令之一是 verifyTextPresent。IDE 说如果文本被更改(这是预期的)会出现错误。
我把记录的测试放到Eclipse中运行,结果说通过了。
现在我已经输入了不同的值,并且从未更改过代码中的值,但是 eclipse 说它运行良好,没有错误。但是当我在 IDE 中运行它时,它说有错误并突出显示错误所在。
当为 verifyTextPresent 输入不同的值时,它为什么不会在 Eclipse 上失败?
这是我使用的代码;
public class MarvinDataTest extends SeleneseTestBase
{
private Selenium selenium;
private String success = "success";
@Before
public void setUp() throws Exception
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:8000/");
selenium.start();
}
@Test
public void testMarvinDataTest() throws Exception
{
selenium.open("/eem/api/v1/metrics/displacement/286");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/displacement/287");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/displacement/288");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
***verifyTrue(selenium.isTextPresent("\"displacement\": 20,"));***
selenium.open("/eem/api/v1/metrics/humidity/286");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/humidity/287");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/humidity/288");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/load/286");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/load/287");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/load/288");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
***verifyTrue(selenium.isTextPresent("\"load\": 4,"));***
selenium.open("/eem/api/v1/metrics/pressure/286");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/pressure/287");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/pressure/288");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/temperature/286");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/temperature/287");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/temperature/288");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
verifyTrue(selenium.isTextPresent("\"temperature\": 17"));
selenium.open("/eem/api/v1/metrics/vibration/286");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/vibration/287");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
selenium.open("/eem/api/v1/metrics/vibration/288");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
***verifyTrue(selenium.isTextPresent("\"vibration\": 4"));***
selenium.open("/eem/api/v1/metrics");
assertEquals("", selenium.getTitle());
verifyTrue(selenium.isTextPresent("success"));
verifyTrue(selenium.isTextPresent("mm"));
verifyTrue(selenium.isTextPresent("%"));
verifyTrue(selenium.isTextPresent("kg"));
verifyTrue(selenium.isTextPresent("N/m"));
verifyTrue(selenium.isTextPresent("C"));
verifyTrue(selenium.isTextPresent("G"));
selenium.addScript("", "");
}
@After
public void tearDown() throws Exception
{
selenium.stop();
}
}
带星号的行中包含错误的数据,应该显示为错误。使用 IDE 时显示错误,但使用 Eclipse 时显示已通过,没有错误。
有人可以解释一下并帮助我找到解决方案吗?