Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.io.PrintStream;
- import java.util.ArrayList;
- import java.util.Scanner;
- import org.openqa.selenium.By;
- import org.openqa.selenium.NoSuchElementException;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.firefox.FirefoxDriver;
- public class Sub
- {
- private static String user;
- private static String password;
- private static int userlenght;
- private static int passwordlenght;
- public static void add()
- throws InterruptedException
- {
- WebDriver driver = new FirefoxDriver();
- int number = 0;
- Scanner input = new Scanner(System.in);
- System.out.println("Podaj link do kanalu (Strony glownej)");
- String link = input.next();
- while (Open.linijki >= 0)
- {
- try
- {
- user = (String)Open.luser.get(number);
- password = (String)Open.lpassword.get(number);
- userlenght = user.length();
- passwordlenght = password.length();
- }
- catch (Exception e)
- {
- System.out.println("Zakonczono dodawania subow");
- driver.close();
- System.exit(0);
- }
- driver.get(link);
- Thread.sleep(3000L);
- try
- {
- driver.findElement(By.className("signin-container")).click();
- Thread.sleep(2000L);
- driver.findElement(By.id("account-chooser-link")).click();
- Thread.sleep(1000L);
- driver.findElement(By.id("edit-account-list")).click();
- Thread.sleep(1000L);
- driver.findElement(By.id("choose-account-0")).click();
- Thread.sleep(1000L);
- driver.findElement(By.id("edit-account-list")).click();
- }
- catch (NoSuchElementException localNoSuchElementException1) {}
- Thread.sleep(1500L);
- WebElement email = driver.findElement(By.id("Email"));
- WebElement next = driver.findElement(By.id("next"));
- for (int i = 0; i < userlenght; i++)
- {
- char uchar = user.charAt(i);
- email.findElement(By.xpath("//input[@id='Email']")).sendKeys(new CharSequence[] { uchar });
- }
- next.click();
- Thread.sleep(3000L);
- WebElement haslo = driver.findElement(By.id("Passwd"));
- for (int i = 0; i < passwordlenght; i++)
- {
- char pchar = password.charAt(i);
- haslo.findElement(By.xpath("//input[@id='Passwd']")).sendKeys(new CharSequence[] { pchar });
- }
- WebElement zaloguj = driver.findElement(By.id("signIn"));
- zaloguj.click();
- Thread.sleep(3000L);
- number++;
- try
- {
- driver.findElement(By.className("yt-uix-button-subscribe-branded"));
- WebElement subscribe = driver.findElement(By.className("primary-header-actions"));
- subscribe.click();
- System.out.println(user + " [OK]");
- }
- catch (NoSuchElementException e)
- {
- System.out.println(user + " [ERROR]");
- }
- Thread.sleep(2000L);
- driver.get("https://youtube.com/logout");
- Open.linijki -= 1;
- Thread.sleep(2500L);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement