Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
1.1k views
in Selenium by
recategorized by

I am not having success trying to identify and click the compose email button in google. Tried various locator techniques like Xpath, Css selector but keep getting the illlegal selector error.

 

Below is my current code for logging in and clicking on the compose button in Gmail,

driver.get("https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/");

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

    driver.findElement(By.id("Email")).sendKeys(email);

    driver.findElement(By.id("Passwd")).sendKeys(Password);

    WebElement stay_signed_in = driver.findElement(By.id("PersistentCookie"));

    //if(stay_signed_in.isSelected())

    //stay_signed_in.click();//

    driver.findElement(By.id("signIn")).click();

    WebDriverWait wait = new WebDriverWait (driver, 15);

    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("div[gh='cm']")));

    WebElement compose_button = driver.findElement(By.xpath("div[gh='cm']"));

    compose_button.click();

1 Answer

0 like 0 dislike
by
selected by
 
Best answer

I was able to find to find this using the following Xpath code,

 

     WebElement compose_button = driver.findElement(By.xpath("//div[@gh='cm']"));


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...