Guest User

Untitled

a guest
Oct 24th, 2016
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. import java.util.concurrent.TimeUnit;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.firefox.FirefoxDriver;
  7.  
  8. public class SytheBump {
  9.  
  10. // private final static GUI2 GUI2 = new GUI2();
  11. private static String username = "haha";
  12. private static String password = "xD";
  13. static WebDriver driver = null;
  14.  
  15. public static void main(String[] args) {
  16.  
  17. // GUI2.setVisible(true);
  18. try {
  19. Thread.sleep((0 * 60 + 0) * 60000);
  20. while (true) {
  21. // File pathBinary = new File(
  22. // "C:\\Program Files\\Mozilla Firefox\\firefox.exe");
  23. // FirefoxBinary Binary = new FirefoxBinary(pathBinary);
  24. // FirefoxProfile firefoxPro = new FirefoxProfile();
  25. // driver = new FirefoxDriver(Binary, firefoxPro);
  26. driver = new FirefoxDriver();
  27. driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  28. driver.manage().window().maximize();
  29. driver.get("http://www.sythe.org/login/");
  30. Thread.sleep(12000);
  31. WebElement name = driver.findElement(By.name("login"));
  32. if (name != null) {
  33. name.sendKeys(username);
  34. } else {
  35. System.out.println("Error 1 logging in!");
  36. continue;
  37. }
  38. WebElement pass = driver.findElement(By.name("password"));
  39. if (pass != null) {
  40. pass.sendKeys(password);
  41. } else {
  42. System.out.println("Error 2 logging in!");
  43. continue;
  44. }
  45. WebElement button = driver
  46. .findElement(By
  47. .cssSelector("#pageLogin > dl.ctrlUnit.submitUnit > dd > input"));
  48. if (button != null) {
  49. button.click();
  50. } else {
  51. System.out.println("Error 3 logging in!");
  52. continue;
  53. }
  54. for (Link l : Link.values()) {
  55. driver.get(l.getPostLink());
  56. Thread.sleep(5500);
  57. WebElement button2 = driver
  58. .findElement(By
  59. .cssSelector("#QuickReply > div.submitUnit > input.button.DisableOnSubmit"));
  60. if (button2 != null) {
  61. button2.click();
  62. } else {
  63. System.out.println("Error 3 for" + l.name());
  64. continue;
  65. }
  66. WebElement button34 = driver
  67. .findElement(By.tagName("body"));
  68. if (button34 != null) {
  69. button34.click();
  70. } else {
  71. System.out.println("Error 1 for" + l.name());
  72. continue;
  73. }
  74. WebElement button3 = driver.findElement(By
  75. .tagName("iframe"));
  76. if (button3 != null) {
  77. button3.sendKeys(l.getMessage());
  78. } else {
  79. System.out.println("Error 5 for" + l.name());
  80. continue;
  81. }
  82. WebElement button4 = driver
  83. .findElement(By
  84. .cssSelector("#ThreadReply > dl.ctrlUnit.submitUnit > dd > input.button.primary"));
  85. if (button4 != null) {
  86. button4.click();
  87. } else {
  88. System.out.println("Error 2 for" + l.name());
  89. continue;
  90. }
  91. Thread.sleep(6500);
  92. }
  93. driver.quit();
  94. Thread.sleep(28788000 - (Link.values().length * 17000));
  95. }
  96. } catch (Exception e) {
  97. e.printStackTrace();
  98. } finally {
  99. if (driver != null) {
  100. driver.quit();
  101. }
  102. }
  103. }
  104. }
Add Comment
Please, Sign In to add comment