How to click on a button

Answered

Hello Friends,

I wanted to know how to click on a LOGIN button in a myntra.com site.


import org.openqa.selenium.By;

import org.openqa.selenium.JavascriptExecutor;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.interactions.Actions;
public class TestCase {
public static WebDriver driver;

public static void main(String[] args) {

driver= new FirefoxDriver();

driver.get("http://myntra.com/");
//driver.findElement(By.xpath("*//a[@class='cart']/a/div/a")).click();
driver.findElement(By.xpath("html/body/div[2]/div/div[1]/div[2]/div[1]/div/a[1]")).click();

}

}

Selenium Train Asked on December 10, 2014 in Selenium WebDriver.
Add Comment
1 Answer(s)
Best answer

HI Try this:


WebDriver driver = new FirefoxDriver ();

driver.get("http://www.myntra.com/");

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

driver.findElement(By.xpath("/html/body/div[1]/div/div[1]/div[2]/div[1]/div/a[1]")).click();

Regards,
Lakshay Sharma

xLov3rDns Professor Answered on December 10, 2014.

It’s working thanks. And apart from absolute xpath any other way to identify this button?.

on December 10, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.