Selenium Assignment – 6 – Flipkart Login

In this sixth selenium Assignment, we will practice some dynamic xpath using different functions.

Scenario:

  • Open a browser of your choice like Mozilla Firefox.
  • Navigate to Flipkart site (http://www.flipkart.com)
  • Enter Email Id or Phone Number.
  • Enter password.
  • Click login button.
  • Verify that user is logged in successfully.

Please follow screenshots for better understanding.

flipkart_home_page

  • Enter valid username and password.

Flipkart_login_page

Try this scenario and send us the code for feedback and assessment, or if you have any questions, queries or comments. Feel free to write us saurabh@qatechhub.com. We will be back soon with next assignment.

Till then, Keep Learning 🙂

Update — Please find the code for this assignment below —

package qatechhub.assignments;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;

public class FlipkartLogin {

	ChromeDriver driver;
	String url = "http://www.flipkart.com";

	public void invokeBrowser() {

		System.setProperty("webdriver.chrome.driver",
				"C:\\Users\\Saurabh Dhingra\\workspace\\libs\\chromeDriver36\\chromedriver.exe");

		driver = new ChromeDriver();

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

		driver.manage().deleteAllCookies();

		driver.manage().timeouts().pageLoadTimeout(90, TimeUnit.SECONDS);

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

		driver.get(url);

	}

	public void loginToFlipkart() {
		driver.findElement(By.xpath("//div[@class='_1XBjg- row']//form//input[@type='text']")).sendKeys("testuser@abc.com");
		
		driver.findElement(By.xpath("//div[@class='_1XBjg- row']//form//input[@type='password']")).sendKeys("Test@1234");
		
		driver.findElement(By.xpath("//div[@class='_1XBjg- row']//form//button[@type='submit']")).click();
		
	}
	
	public void closeBrowser() {
		driver.quit();
	}

}

 

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: