How can I login to flipkart using selenium?

0 votes
I am working with selenium webdriver and its fun till now. I am trying to login to flipkart now and its pretty mess there. I am unable to get an ID there and locating elements using class name is also not working. Can someone help me with this?
Dec 20, 2018 in Selenium by Jino
• 5,560 points
1,173 views

1 answer to this question.

0 votes

Hey @Jino, glad you are liking selenium but there are many more things to selenium. Anyways, you can use different types of locators to find element.

Here is what I used the basic one using Xpath, take a look.

driver.get("https://www.flipkart.com");
driver.findElement(By.className("_2zrpKA")).sendKeys("email@gmail.com");
driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div[2]/div/form/div[2]/input")).sendKeys("pa55word");
driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div[2]/div/form/div[3]/button")).click();

Try this, it works. 

answered Dec 20, 2018 by Nabarupa
package Webbasics;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class FlipkartLogin {

public static void main(String[] args) {

// TODO Auto-generated method stub

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

WebDriver driver=new ChromeDriver();

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

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

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

driver.findElement(By.xpath("(//input[@type='text'])[2]")).sendKeys("bhargav@gmail.com");

driver.findElement(By.xpath("//input[@type='password']")).sendKeys("Bhargav");

driver.findElement(By.xpath("(//button[@type='submit'])[2]")).click();

}

}
Hi M Bhargav, thanks for sharing the solution for this problem. It worked well for me.

Related Questions In Selenium

0 votes
1 answer

How can I send some data to a Prompt Alert box using Selenium Webdriver?

Hey Abhishek, you can use sendKeys() method ...READ MORE

answered Jul 2 in Selenium by Abha
• 27,180 points
78 views
0 votes
1 answer

How can I download the *.jar file from http:// seleniumhq.org using selenium WebDriver?

For Selenium Standalone Server use this: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); and ...READ MORE

answered Apr 9, 2018 in Selenium by Martin
• 4,220 points
601 views
0 votes
1 answer

How can I implement Selenium using C#?

Reference https://www.seleniumhq.org/docs/03_webdriver.jsp#the-5-minute-getting-started-guide using OpenQA.Selenium.Firefox; using OpenQA.Selenium; class GoogleSuggest { ...READ MORE

answered Apr 9, 2018 in Selenium by Neville
48 views
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,130 points
344 views
0 votes
1 answer

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,110 points
934 views
0 votes
1 answer
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,130 points
1,115 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
856 views
+9 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,270 points
70,061 views
+4 votes
1 answer

How can I configure Eclipse for using Selenium?

Follow the following steps to configure your ...READ MORE

answered Dec 12, 2018 in Selenium by Nabarupa
255 views