This is an element from Gmail, exactly the "Compose" button. Look the id, it is ":il" when i don't have unread messages.
<div id=":il" class="aic">
<div class="z0">
<div class="T-I J-J5-Ji T-I-KE L3" tabindex="0" role="button" style="-moz-user-select: none;" gh="cm">COMPOSE</div>
</div>
</div>
Now I just sent an email to myself, and log off my account and log in again. When I inspect the element the id has changed to ":3l".
<div id=":3l" class="aic">
<div class="z0">
<div class="T-I J-J5-Ji T-I-KE L3 T-I-JO" tabindex="0" role="button" style="-moz-user-select: none;" gh="cm">COMPOSE</div>
</div>
</div>
Then i read the mail, log off and log in again. When i read the element i am getting the original id ":il".
Why does Gmail change id elements of some elements? I am working with WebDriver and Java and this is driving me crazy. May be I have to change the way to locate this element.
Best Regards!
Added my test coded:
public static void main(String[] args)
{
WebDriver driver;
String baseUrl;
driver = new FirefoxDriver();
baseUrl = "https://www.google.com.ar/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(baseUrl + "/?gfe_rd=cr&ei=Tf_YVKv1G6yB8Qe_24HYDA&gws_rd=ssl");
driver.findElement(By.linkText("Gmail")).click();
driver.findElement(By.id("Passwd")).clear();
driver.findElement(By.id("Passwd")).sendKeys("Not neccesary :D");
driver.findElement(By.id("Email")).clear();
driver.findElement(By.id("Email")).sendKeys("Not_neccesary_:D");
driver.findElement(By.id("signIn")).click();
//APARENTLY THERE ARE PROBLEMS WHEN I HAVE MESSAGES UNREADED
driver.findElement(By.xpath("//div[.='COMPOSE']")).click();
driver.findElement(By.id(":uv")).sendKeys("Not_neccesary_:D@gmail.com");
driver.findElement(By.id(":ul")).sendKeys("Test");
driver.findElement(By.id(":vn")).sendKeys("aaaaaaaaaaa");
driver.findElement(By.id(":ub")).click();
driver.close();
}