Guest User

Untitled

a guest
Jun 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package example;
  2.  
  3. import org.junit.Before;
  4. import org.junit.Test;
  5.  
  6. import com.thoughtworks.selenium.SeleneseTestCase;
  7.  
  8. public class GoogStringTest extends SeleneseTestCase {
  9.  
  10. private final String DIRECTORY_PREFIX =
  11. "file:///C:/Users/mbolin/workspace/closure-library/";
  12.  
  13. @Override
  14. @Before
  15. public void setUp() throws Exception {
  16. final String url = DIRECTORY_PREFIX;
  17. final String browserString = "*firefox";
  18. // This initializes the protected "selenium" field with the base URL for the
  19. // tests and the browser to use when running the tests.
  20. setUp(url, browserString);
  21. }
  22.  
  23. @Test
  24. public void testGoogString() throws Exception {
  25. // Opens the URL in Firefox.
  26. selenium.open(DIRECTORY_PREFIX + "closure/goog/string/string_test.html");
  27.  
  28. // Because the test runs automatically when the HTML file is loaded, poll
  29. // for up to 5 seconds to see whether the test is complete.
  30. selenium.waitForCondition(
  31. "window.G_testRunner && window.G_testRunner.isFinished()",
  32. "5000");
  33.  
  34. // Invoke this snippet of JavaScript in the browser to query whether the
  35. // test succeeded or failed.
  36. String success = selenium.getEval("window.G_testRunner.isSuccess()");
  37. boolean isSuccess = "true".equals(success);
  38. if (!isSuccess) {
  39. // If the test failed, report the reason why.
  40. String report = selenium.getEval("window.G_testRunner.getReport()");
  41. fail(report);
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment