Advertisement
Guest User

Untitled

a guest
Mar 28th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. package main;
  2.  
  3. import java.io.PrintStream;
  4. import java.util.ArrayList;
  5. import java.util.Scanner;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.NoSuchElementException;
  8. import org.openqa.selenium.WebDriver;
  9. import org.openqa.selenium.WebElement;
  10. import org.openqa.selenium.firefox.FirefoxDriver;
  11.  
  12. public class Sub
  13. {
  14. private static String user;
  15. private static String password;
  16. private static int userlenght;
  17. private static int passwordlenght;
  18.  
  19. public static void add()
  20. throws InterruptedException
  21. {
  22. WebDriver driver = new FirefoxDriver();
  23. int number = 0;
  24. Scanner input = new Scanner(System.in);
  25. System.out.println("Podaj link do kanalu (Strony glownej)");
  26. String link = input.next();
  27. while (Open.linijki >= 0)
  28. {
  29. try
  30. {
  31. user = (String)Open.luser.get(number);
  32. password = (String)Open.lpassword.get(number);
  33. userlenght = user.length();
  34. passwordlenght = password.length();
  35. }
  36. catch (Exception e)
  37. {
  38. System.out.println("Zakonczono dodawania subow");
  39. driver.close();
  40. System.exit(0);
  41. }
  42. driver.get(link);
  43. Thread.sleep(3000L);
  44. try
  45. {
  46. driver.findElement(By.className("signin-container")).click();
  47. Thread.sleep(2000L);
  48. driver.findElement(By.id("account-chooser-link")).click();
  49. Thread.sleep(1000L);
  50. driver.findElement(By.id("edit-account-list")).click();
  51. Thread.sleep(1000L);
  52. driver.findElement(By.id("choose-account-0")).click();
  53. Thread.sleep(1000L);
  54. driver.findElement(By.id("edit-account-list")).click();
  55. }
  56. catch (NoSuchElementException localNoSuchElementException1) {}
  57. Thread.sleep(1500L);
  58. WebElement email = driver.findElement(By.id("Email"));
  59. WebElement next = driver.findElement(By.id("next"));
  60. for (int i = 0; i < userlenght; i++)
  61. {
  62. char uchar = user.charAt(i);
  63. email.findElement(By.xpath("//input[@id='Email']")).sendKeys(new CharSequence[] { uchar });
  64. }
  65. next.click();
  66. Thread.sleep(3000L);
  67. WebElement haslo = driver.findElement(By.id("Passwd"));
  68. for (int i = 0; i < passwordlenght; i++)
  69. {
  70. char pchar = password.charAt(i);
  71. haslo.findElement(By.xpath("//input[@id='Passwd']")).sendKeys(new CharSequence[] { pchar });
  72. }
  73. WebElement zaloguj = driver.findElement(By.id("signIn"));
  74. zaloguj.click();
  75. Thread.sleep(3000L);
  76. number++;
  77. try
  78. {
  79. driver.findElement(By.className("yt-uix-button-subscribe-branded"));
  80. WebElement subscribe = driver.findElement(By.className("primary-header-actions"));
  81. subscribe.click();
  82. System.out.println(user + " [OK]");
  83. }
  84. catch (NoSuchElementException e)
  85. {
  86. System.out.println(user + " [ERROR]");
  87. }
  88. Thread.sleep(2000L);
  89. driver.get("https://youtube.com/logout");
  90. Open.linijki -= 1;
  91. Thread.sleep(2500L);
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement