Quality Testing

Quality is delighting customers

Unable to click on "All" of gmail -> Refer image

Using selenium web driver i am not able to click on "All".

May be it is very hard.

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class First {


public static void main(String[] args) throws InterruptedException {

WebDriver driver = new FirefoxDriver();
//WebElement mElement;

driver.get("http://google.com");
driver.findElement(By.xpath(".//*[@id='gbw']/div/div/div[1]/div[1]/a")).click();
driver.findElement(By.id("Email")).sendKeys("");
driver.findElement(By.xpath("html/body/div[1]/div[2]/div[2]/div[1]/form/div[1]/div/input")).click();
Thread.sleep(2000);
driver.findElement(By.id("Passwd")).sendKeys("");
driver.findElement(By.xpath(".//*[@id='signIn']")).click();
//Thread.sleep(2000);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

driver.findElement(By.xpath("//div[@style='position: relative; min-height: 100%;']/div[3]/div/div[2]/div/div[2]/div/div/div/div[1]/div/div[1]/div[1]/div/div/div[1]/div/div/div")).click();

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.xpath("//[@class='SK AX']/div/")).click();
//mElement = driver.findElement(By.cssSelector(".G-Ni.J-J5-Ji+.J-M.jQjAxd .SK .J-N:first-child div"));
//driver.findElement(By.xpath("//*[contains(text(), 'All')]")).click();
//mElement.click();
//System.out.println("This is test" +mElement+"sdsd"+mElement.getText());
}

}

Views: 260

Reply to This

Replies to This Discussion

Please any one can help

As it is invalid xpath "driver.findElement(By.xpath("//[@class='SK AX']/div/")).click();" it couldn't able find the correct element. Instead of above please use the below one It is working fine.

driver.findElement(By.xpath(".//*[@id=':l4']/div")).click();

I hope it helps.

no it is not working.. :(

That was working fine. Today I checked it was not working. 

Check this: 

Thread.sleep(1000);

driver.findElement(By.xpath(".//*[@id=':l4'][@selector='all']")).click();

It works fine for me. Please check & let me know.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service