Sheikh Rahman Sheikh Rahman - 9 days ago 6
Java Question

xpath in firebug works however sendkey is not sending value

I am trying to write a login code for hotmail. I asked this a few days ago on how to get the xpath, someone answered and gave me the correct xpath in his reply:

//*[@id='CredentialsInputPane']//div[3]//div[2]/div


His answer worked.

Today I tried to come up with my own xpath solution and in Firepath when I use the following syntax it highlights the user name field.

//div[contains(@class,'placeholder has-focus')][text()='Email, phone, or Skype name']


Question/problem: When I run the test, in UI it does not send the value user@msn.com, it clicks the Next button and I get error "Please enter a value".

What is wrong with my xpath syntax, even though it is highlighting the field? Why is it not sending the email id?

Code:

driver.get("https://login.live.com/login.srf?");
driver.findElement(By.xpath("//div[contains(@class,'placeholder')][text()='Email, phone, or Skype name']")).sendKeys("usertest81@msn.com");

driver.findElement(By.xpath("//input[contains(@id,'idSIButton9')]")).click();


Thanks in advance for your time and explanation.

Answer

You are trying to send value to a non-input field. This may be the reason. Try with the following-

driver.findElement(By.name("loginfmt")).sendKeys("usertest81@msn.com");