0

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..

3
  • What's the problem ? It looks like the assertion is just failing because the text does not exist at that page ? Commented Jun 4, 2011 at 17:11
  • Yes, this is look like, but the text exist... after i be logged in Gmail.. Commented Jun 4, 2011 at 17:15
  • apparently the problem occurs after I already be logged in to gmail, because on the front page asserts happen successfully ... Commented Jun 4, 2011 at 17:29

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi, I try do this, but dont work too, i am try do this with Watir too, but have the same probleam, after login i have error to the a text via xpath for example ... usgin a Thread sleep too....
0

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

2 Comments

in log eclipse Default test Tests run: 1, Failures: 0, Skips: 0 Configuration Failures: 1, Skips: 0
Hi, i note that any app then i need login asserts dont work fine, for exemple, for gmail initial page(before login) asserts work very well, but after login no. This for any application... i dont have idea why this happen... thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.