selenium - Email is not taken or not sending a key through xpath -
I am starting at Selenium WebDriver and I'm trying to login via Gmail account Expect, now the problem It is that I have got xpath for an email and send a key to it when we run the key sent to the password field instead of the email, so please help solve it. Here is my code:
Using the public class Xpath {stable Boolean C, C1, C2; Public static zero main throws an exception (string [] args) {/ TODO auto generated method stub WebDriver wD = new FirefoxDriver (); WD.get ("https://www.gmail.com/"); Thread.Sleep (2000); C = wD.findElement (By.xpath ("/ html / body / div / div [2] / div [2]")) isDisplayed () .; If (c == true) {System.out.println ("signin board is present"); } C1 = wD.findElement (By.xpath ("/ html / body / div / div [2] / div [2] / form")). IsDisplayed (); If (c1 == true) {System.out.println ("form exists"); } C2 = wD.findElement (by.expath ("/ html / body / div / div [2] / div [2] / form / input [15]")). IsDisplayed (); If (c1 == true) {System.out.println ("email field exists"); } WebElement emailInput = wD.findElement (By.xpath ("/ html / body / div / div [2] / div [2] / form / input [15]"); EmailInput.clear (); EmailInput.sendKeys ("xyz@gmail.com"); WD.quit (); }
Do not use absolute xpathes if you use some Xpath browser plug-ins Do fireups for firefath disable disable xpath output.
Then your expressions can look like this:
-
// [id = 'gaia_loginform'] // input [@ id = 'email'] - For email input
-
// form [@ id = 'gaia_loginform'] // input [@ id = 'password'] - for password input
< / Li>
Comments
Post a Comment