Reputation: 4257
Hello I am with the following test with selenium, but I'm having to run it an error:
public class TestExemplo extends SeleneseTestNgHelper {
@Test public void testUntitled() throws Exception {
selenium.open("http://gmail.com");
selenium.type("Email", "edipofederle");
selenium.type("Passwd", "pass");
selenium.click("signIn");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("You are currently"));
}
}
java.lang.AssertionError: null
at com.thoughtworks.selenium.SeleneseTestBase.fail(SeleneseTestBase.java:372)
at com.thoughtworks.selenium.SeleneseTestBase.assertTrue(SeleneseTestBase.java:377)
at com.thoughtworks.selenium.SeleneseTestBase.assertTrue(SeleneseTestBase.java:381)
at com.example.tests.TestExemplo.testUntitled(TestExemplo.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
Could someone help me with this? Thanks..
Upvotes: 0
Views: 10913
Reputation: 10908
It could be that the text you are checking for is being loaded by JavaScript after the page has loaded. This would mean that at the time the assertTrue()
is called the text is not yet present. You could either try a waitForCondition()
or just a plain Thread.sleep()
so that the text has a chance to populate before the assertTrue()
runs.
Upvotes: 1
Reputation: 1247
The problem is that your Selenium driver thinks that the text does not exist and hence is returning false. Your assertion is failing because of that.
Can you check what the getHtmlSource method's output looks like? May be paste it here so that the presence of that text (or absence) can be
Pavan
Upvotes: 0