Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,I am learning Selenium Webdriver. I was trying to login "Quora" through Google. but in the email typing section, the code is not working. I am not able to figure out what is the problem. Please help. Below is my code


import org.openqa.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Demo2 {
	public static void main(String[] args) { 
		System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
		WebDriver driver=new ChromeDriver();
		String url="https://quora.com";
		driver.get(url);
		WebElement ele1=driver.findElement(By.className("google_button_text"));
		ele1.click();
		
		//WebElement e1=driver.findElement((By.xpath("//*[@id='identifierId']")));
		//e1.sendKeys("Welcome");
		
		WebElement email1=driver.findElement(By.name("identifier"));
		email1.sendKeys("fggffgfd"); 
		WebElement next1=driver.findElement(By.className("RveJvd snByac")); //whsOnd zHQkBf
		next1.click();
		WebElement password=driver.findElement(By.className("whsOnd zHQkBf"));
		password.click();
		password.sendKeys("Sffgdffdf3");
		WebElement next2=driver.findElement(By.className("RveJvd snByac")); //whsOnd zHQkBf
		next2.click();
		
		
		
	}
}


What I have tried:

import org.openqa.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Demo2 {
	public static void main(String[] args) { 
		System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
		WebDriver driver=new ChromeDriver();
		String url="https://quora.com";
		driver.get(url);
		WebElement ele1=driver.findElement(By.className("google_button_text"));
		ele1.click();
		
		//WebElement e1=driver.findElement((By.xpath("//*[@id='identifierId']")));
		//e1.sendKeys("Welcome");
		
		WebElement email1=driver.findElement(By.name("identifier"));
		email1.sendKeys("fggffgfd"); 
		WebElement next1=driver.findElement(By.className("RveJvd snByac")); //whsOnd zHQkBf
		next1.click();
		WebElement password=driver.findElement(By.className("whsOnd zHQkBf"));
		password.click();
		password.sendKeys("Sffgdffdf3");
		WebElement next2=driver.findElement(By.className("RveJvd snByac")); //whsOnd zHQkBf
		next2.click();
		
		
		
	}
}
Posted
Updated 14-Mar-18 23:31pm

I was also getting the same error for "google.com", and after so many efforts, I came to know that the id of the input box is different in chrome and firefox. And I was picking the id from chrome but I was executing my script on chrome.

So please check your locators properly the problem will be in locators only.
 
Share this answer
 
I resolved this error by updating my chrome driver to the latest version. Download the latest and replace it with older version.
Here is the link to latest version:
Downloads - ChromeDriver - WebDriver for Chrome[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900