Quick Search:

View

Revision:

Diff

Diff from 2365 to:

Annotations

Annotate by Age | Author | None
/fisheye/browse/selenium-rc/trunk/tests/generated/src/test/java/com/thoughtworks/selenium/thirdparty/SessionExtensionJsTest.java

Annotated File View

gyrm
2292
1 package com.thoughtworks.selenium;
2
3 import org.openqa.selenium.server.RemoteControlConfiguration;
4
5 import junit.framework.TestCase;
6
ph7
2365
7 public class SessionExtensionJsTest extends SeleneseTestCase {
8
gyrm
2292
9     private static final String TEST_URL = "http://www.google.com";
ph7
2365
10
11     @Override
12     public void setUp(String urlString browserStringthrows Exception {
13        setTestContext();
gyrm
2292
14     }
ph7
2365
15
16     @Override
17     public void tearDown() throws Exception {    
gyrm
2292
18     }
ph7
2365
19
gyrm
2292
20     public void testLoadSimpleExtensionJs() {
gyrm
2293
21         // expect failure when the extension isn't set
gyrm
2292
22         Selenium selenium = getNewSelenium();
23         try {
gyrm
2293
24             runCommands(selenium);
25             fail("Expected SeleniumException but none was encountered");
gyrm
2292
26         }
27         catch (SeleniumException se) {
gyrm
2293
28             assertTrue(se.getMessage().endsWith("comeGetSome is not defined"));
gyrm
2292
29         }
30         finally {
gyrm
2293
31             selenium.stop();
gyrm
2292
32         }
33
34         // everything is peachy when the extension is set
35         selenium = getNewSelenium();
36         selenium.setExtensionJs("var comeGetSome = 'tn';");
37         runCommands(selenium);
38         assertEquals("Klaatu barada nikto - Google Search",
39             selenium.getTitle());
40         selenium.stop();
gyrm
2293
41         
42         // reusing the session ... extension should still be available
43         runCommands(selenium);
44         assertEquals("Klaatu barada nikto - Google Search",
45             selenium.getTitle());
46         selenium.stop();
gyrm
2292
47     }
ph7
2365
48
49     private Selenium getNewSelenium() {
50         return new DefaultSelenium("localhost",
51             RemoteControlConfiguration.getDefaultPort(), runtimeBrowserString(), TEST_URL);
52     }
53
54     private void runCommands(Selenium selenium) {
55         selenium.start();
56         selenium.open(TEST_URL);
57         selenium.type("q""Klaatu barada nikto");
58         selenium.click("javascript{ 'b' + comeGetSome + 'G' }");
59         selenium.waitForPageToLoad("5000");
60     }
61
gyrm
2292
62 }
    \ No newline at end of file