How to automate instagram login page using java in selenium?

+1 vote

Using below code i am able to open Instagram but i am not able enter user name password and further process please help

package logintesting;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.Keys;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

public class Loginpage  {

public static void main(String[] args)  {

System.setProperty("webdriver.chrome.driver","D:\\selenium\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

//driver.get("https://www.google.com/");

driver.get("https://www.instagram.com/");

driver.manage().window().maximize();

WebElement e = driver.findElement(By.name("q"));

e.sendKeys("Instagram");

e.submit();

//WebElement click = driver.findElement(By.xpath("//div[@class='g']//div//div[@class='rc']//h3[@class='LC20lb DKV0Md'][contains(text(),'Instagram')]]"));

//click.click();

driver.findElement(By.name("UserName")).sendKeys("xyz");

driver.findElement(By.name("password")).sendKeys("abci");

driver.findElement(By.xpath("//div[text()='Log In']")).click();
Sep 15 in Selenium by anonymous
• 410 points
214 views

1 answer to this question.

+1 vote
Best answer

Try the following:

package com.company;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.By;
import java.util.concurrent.TimeUnit;

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

        ChromeDriver driver = new ChromeDriver();
        driver.get("https://www.instagram.com/accounts/login/?hl=en&source=auth_switcher");

        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        driver.findElement(By.name("username")).sendKeys("username");
        driver.findElement(By.name("password")).sendKeys("password");
        driver.findElement(By.xpath("//div[text()='Log In']")).click();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }
}
answered Sep 15 by Karan
• 19,080 points

selected Sep 17 by Jordan

Related Questions In Selenium

+10 votes
15 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,360 points
122,363 views
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 5 in Selenium by Sri
• 2,970 points
13,591 views
+1 vote
2 answers
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,520 points
4,532 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
3,819 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,802 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,767 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,143 views
+1 vote
1 answer

How can I automate the process of adding iPhone to cart in Flipkart using Selenium(java),Page Object Model and TestNG? Also validate if product is added and available in cart?

Hey check this https://www.edureka.co/community/47160/automate-purchase-adding-book-cart-flipkart-using-selenium? It deals with a similar ...READ MORE

answered Jan 13 in Selenium by Karan
• 19,080 points
2,743 views
+1 vote
2 answers