Siva Kumar
Siva Kumar

Reputation: 1

Syntax error on token in driver.findby Xpath

I am new to selenium, and i m trying to automate the facebook registration on Google chrome. I have setup eclipse & Chrome driver and have created all the jar files. Now I copied the Xpath of a textbox in facebook page by Inspect Element option and pasted the Xpath of the element as follows:

driver.findElement(By.xpath("//*[@id="email"]]")).sendkeys("user1");

But i am getting two errors in this. 1 is The left hand side of an assignment must be variable. 2. is Syntax error on token "email".

I also tried the syntax below:

WebElement el = driver.findElement(By.xpath("//[@id="email"]")).sendkeys("user1");

But thats not working too. Please let me know what am i missing here.

Upvotes: 0

Views: 2050

Answers (2)

Guy
Guy

Reputation: 50864

It should be "//*[@id='email']" with single quotations around "email". It should also be sendKeys with capital 'K'

driver.findElement(By.xpath("//*[@id='email']")).sendKeys("user1");

Upvotes: 2

noor
noor

Reputation: 3004

try by using this cssSelector:

Thread.sleep(5000);        
driver.findElement(By.cssSelector("input.inputtext#email")).sendKeys("abc");

Upvotes: 0

Related Questions