I wrote a Selenium script to increase the number of views of my youtube video. The current view count is: 164, I would like to increase this by 100. Here is my code below. The problem is that it seems that the browser automation does not increase the count even though the web page is accessed 100 times, what is the reason? Any fix? I was thinking maybe they know that I am accessing the website from the same IP address, maybe a change of IP address could fix this? If yes, how?
package Test;
// Generated by Selenium IDE
import org.junit.Before;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.After;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Keys;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;
public class YoutubeAutomation {
private static WebDriver driver;
private Map<String, Object> vars;
JavascriptExecutor js;
@BeforeEach
public void setUp() {
driver = new ChromeDriver();
js = (JavascriptExecutor) driver;
vars = new HashMap<String, Object>();
}
@AfterAll
public static void tearDown() {
driver.quit();
}
public String waitForWindow(int timeout) {
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
e.printStackTrace();
}
Set<String> whNow = driver.getWindowHandles();
Set<String> whThen = (Set<String>) vars.get("window_handles");
if (whNow.size() > whThen.size()) {
whNow.removeAll(whThen);
}
return whNow.iterator().next();
}
@Test
public void test() throws InterruptedException {
String[] videosURLs = {"https://www.youtube.com/watch?v=sZ86JHQ9TCA&ab_channel=MounaCameliaHammoudi"
// , "https://www.youtube.com/watch?v=4nYbkKicMmA&ab_channel=MounaCameliaHammoudi",
// "https://www.youtube.com/watch?v=b2F8AoqdHTs&ab_channel=MounaCameliaHammoudi",
// "https://www.youtube.com/watch?v=sZ86JHQ9TCA&ab_channel=MounaCameliaHammoudi",
// "https://www.youtube.com/watch?v=yhK5r9uyBTo&t=508s&ab_channel=MounaCameliaHammoudi",
// "https://www.youtube.com/watch?v=wgWxpdx8UGM&ab_channel=MounaCameliaHammoudi",
// "https://www.youtube.com/watch?v=NC7Xq9CdBVk&ab_channel=MounaCameliaHammoudi",
// "https://www.youtube.com/watch?v=kdtn4RYgCYM&ab_channel=MounaCameliaHammoudi"
};
for(int i=0; i<100; i++) {
for( String videoURL: videosURLs) {
driver.get(videoURL);
System.out.println("MOUNA CAMELIA "+i+" "+videoURL);
}
}
}
}
I think views does not count when minimum watching time is not reached & of cours one ip adresse will not work to increase your views, you should alway change it & for fix ip adresse problem you can use vpn extenion with selenium i do something similar in that repo if you want to see : Youtube_Watch_Bot