1 package com.atlassian.selenium;
2
3 import com.atlassian.performance.junit.PerformanceTest;
4 import com.atlassian.performance.TimeRecorder;
5 import junit.framework.TestCase;
6
7
8
9
10
11
12 public abstract class SeleniumTest extends TestCase implements PerformanceTest
13 {
14 protected SeleniumAssertions assertThat;
15 protected SeleniumClient client;
16 protected SeleniumConfiguration config;
17 protected TimeRecorder recorder;
18
19 public abstract SeleniumConfiguration getSeleniumConfiguration();
20
21
22
23
24
25
26 public final void setUp() throws Exception
27 {
28 super.setUp();
29 config = getSeleniumConfiguration();
30
31 if (SeleniumStarter.getInstance().isManual())
32 {
33 SeleniumStarter.getInstance().start(config);
34 }
35
36 client = getSeleniumClient();
37 recorder = new TimeRecorder(this.getClass().getName());
38
39 assertThat = new SeleniumAssertions(client, config, recorder);
40 onSetUp();
41 }
42
43
44
45
46
47
48 protected SeleniumClient getSeleniumClient()
49 {
50 return SeleniumStarter.getInstance().getSeleniumClient(getSeleniumConfiguration());
51 }
52
53
54
55
56 protected void onSetUp() throws Exception
57 {
58 }
59
60
61
62
63
64 public final void tearDown() throws Exception
65 {
66 super.tearDown();
67 onTearDown();
68
69 if (SeleniumStarter.getInstance().isManual())
70 {
71 SeleniumStarter.getInstance().stop();
72 }
73 }
74
75
76
77
78 protected void onTearDown() throws Exception
79 {
80 }
81
82 public TimeRecorder getRecorder()
83 {
84 return recorder;
85 }
86 }