Advertisement
zontak

Untitled

Oct 13th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. package com.example.tests;
  2.  
  3. import com.thoughtworks.selenium.*;
  4. import org.junit.After;
  5. import org.junit.Before;
  6. import org.junit.Test;
  7. import static org.junit.Assert.*;
  8. import java.util.regex.Pattern;
  9.  
  10. public class softunitest {
  11. private Selenium selenium;
  12.  
  13. private String[] users;
  14.  
  15. @Before
  16. public void setUp() throws Exception {
  17. selenium = new DefaultSelenium("localhost", 4444, "*chrome", "https://softuni.bg/");
  18. selenium.start();
  19.  
  20. users = new String[] { "zontak", "RoYaL", "wartus", "aluin" };
  21. }
  22.  
  23. @Test
  24. public void testSoftunitest() throws Exception {
  25.  
  26. for (int i = 0; i < 1000; i++) {
  27.  
  28. selenium.open("https://softuni.bg/");
  29.  
  30. selenium.click("id=search-input");
  31.  
  32. selenium.type("id=search-input", users[i]);
  33. selenium.click("//form[@id='search-form']/button");
  34. selenium.waitForPageToLoad("30000");
  35.  
  36. if (selenium.isElementPresent(
  37.  
  38. selenium.click("//div/a/span");
  39. selenium.waitForPageToLoad("30000");
  40.  
  41. }
  42.  
  43. }
  44.  
  45. private void click(String element) {
  46. if (this.selenium.isElementPresent(element) {
  47. this.selenium.click(element);
  48. } else {
  49. this.click(element);
  50. }
  51. }
  52.  
  53. @After
  54. public void tearDown() throws Exception {
  55. selenium.stop();
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement