Simple testGoogle script should be dead simple

4 views
Skip to first unread message

David Schulberg

unread,
Jul 29, 2009, 9:43:55 PM7/29/09
to selenium-users...@googlegroups.com
Hi,

I have a JUnit test case in Eclipse in which the operative function is

{code:java}    public void testGoogle() throws Throwable {\\         selenium.open("http://www.google.com/webhp?hl=en");\\         assertEquals("Google", selenium.getTitle());\\         selenium.type("q", "Selenium OpenQA");\\         assertEquals("Selenium OpenQA", selenium.getValue("q"));\\         selenium.click("btnG");\\         selenium.waitForPageToLoad("5000");\\         String title = selenium.getTitle();\\         assertEquals("Selenium OpenQA – Google Search", selenium.getTitle());\\     }{code}

Now I am relatively new to Selenium and am wondering about a couple of things with this simple script.

Where is the btnG defined as being the Google Seach button?
The last assert fails (see stack trace below) even though the title seems to match. I also observe in the output from the Selenium server window that the title is returned prefixed with "OK,". What's going on here?

{code:plain}junit.framework.ComparisonFailure: null expected:<Selenium OpenQA [–] Google Search> but was:<Selenium OpenQA [-] Google Search>\\ &nbsp;&nbsp;&nbsp; at junit.framework.Assert.assertEquals(Assert.java:81)\\ &nbsp;&nbsp;&nbsp; at junit.framework.Assert.assertEquals(Assert.java:87)\\ &nbsp;&nbsp;&nbsp; at com.testscripts.GoogleTest.testGoogle(GoogleTest.java:30)\\ &nbsp;&nbsp;&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\\ &nbsp;&nbsp;&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\\ &nbsp;&nbsp;&nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\\ &nbsp;&nbsp;&nbsp; at java.lang.reflect.Method.invoke(Unknown Source)\\ &nbsp;&nbsp;&nbsp; at junit.framework.TestCase.runTest(TestCase.java:168)\\ &nbsp;&nbsp;&nbsp; at junit.framework.TestCase.runBare(TestCase.java:134)\\ &nbsp;&nbsp;&nbsp; at junit.framework.TestResult$1.protect(TestResult.java:110)\\ &nbsp;&nbsp;&nbsp; at junit.framework.TestResult.runProtected(TestResult.java:128)\\ &nbsp;&nbsp;&nbsp; at junit.framework.TestResult.run(TestResult.java:113)\\ &nbsp;&nbsp;&nbsp; at junit.framework.TestCase.run(TestCase.java:124)\\ &nbsp;&nbsp;&nbsp; at junit.framework.TestSuite.runTest(TestSuite.java:232)\\ &nbsp;&nbsp;&nbsp; at junit.framework.TestSuite.run(TestSuite.java:227)\\ &nbsp;&nbsp;&nbsp; at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:91)\\ &nbsp;&nbsp;&nbsp; at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)\\ &nbsp;&nbsp;&nbsp; at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)\\ &nbsp;&nbsp;&nbsp; at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)\\ &nbsp;&nbsp;&nbsp; at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)\\ &nbsp;&nbsp;&nbsp; at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)\\ &nbsp;&nbsp;&nbsp; at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
{code}
David
{emoticon:__jive_emoticon_name=confused}

Reply all
Reply to author
Forward
0 new messages