Instagram Registering with Java

HansSepp

Newbie
Joined
Mar 15, 2017
Messages
10
Reaction score
0
Hey there, so the question is basically in the title, how would i go about this? Worked a bit with C# about that before, but didn't get it working there either, definitely preferring java, though.

Thanks for any help. :)
 
You need to add Selenium or HtmlUnit and use these headless browsers (or Chrome/Firefox drivers). Maybe later in the day I can write something more detailed if you want.
 
You need to add Selenium or HtmlUnit and use these headless browsers (or Chrome/Firefox drivers). Maybe later in the day I can write something more detailed if you want.
If you want, would be really helpful.
 
Tested, works:

Code:
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;

public class Main {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver","your path to chromdriver");

        ChromeDriver driver = new ChromeDriver();
        driver.get("https://www.instagram.com/?hl=en");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.name("emailOrPhone")).sendKeys("[email protected]");
        driver.findElement(By.name("fullName")).sendKeys("Your Name");
        driver.findElement(By.name("username")).sendKeys("Your_username_xyz");
        driver.findElement(By.name("password")).sendKeys("yourpassword");
        driver.findElements(By.tagName("button")).get(1).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }
}

You need to add Selenium jar to project and also download chromedriver.
 
Oh and of course if you add wrong/invalid data to the input fields it won't log in...
 
Back
Top