Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 6th, 2012  |  syntax: None  |  size: 1.55 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class junitTestCaseName extends TestCase {              
  2.         private Properties properties;
  3.         private Selenium selenium;
  4.         public void setUp() {
  5.                 properties = new Properties();
  6.                 try {
  7.                         properties.load(
  8.                         getClass().
  9.                         getClassLoader().
  10.                         getResourceAsStream("my.properties"));
  11.                 } catch (IOException e) {
  12.                         throw new RuntimeException(e);
  13.                   }
  14.                  
  15.                 selenium = new DefaultSelenium(
  16.                                 properties.getProperty("host"),
  17.                                 Integer.valueOf(properties.getProperty("port")),
  18.                                 properties.getProperty("browser"),
  19.                                 properties.getProperty("site"));
  20.                selenium.start();
  21.        }
  22.        public void testValidRegisration() {
  23.             selenium.open(properties.getProperty("accountPage"));
  24.             selenium.type("edit-name", properties.getProperty("user"));
  25.             selenium.type("edit-pass", properties.getProperty("password"));
  26.            selenium.click("//input[@id='edit-submit' and @name='op' and @value='Log in']");
  27.             selenium.waitForPageToLoad(“30000”));
  28.             assertEquals(true, selenium.isTextPresent("Hello, User."));
  29.             selenium.click("link=Log out " + properties.getProperty("userName"));
  30.             selenium.waitForPageToLoad(“30000”));
  31.        }
  32.  
  33.        public void tearDown() {
  34.               selenium.stop();
  35.        }
  36. }