I have a school project where I want to sign into Google Drive with Selenium-Java and the code to use the "Enter Email or Phone" Box always says it cannot find that element. I have tried every single method of findElement. Css-selector, ID, Linktext, Name, xPath. All of them lead to "NoSuchElementException".
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebDriver;
import java.util.Scanner;
public class finalProject {
static WebDriver driver;
static Scanner s = new Scanner(System.in);
public static void launchBrowser() {
// looking through my PC and running the chrome webdriver .exe file
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Lupus\\Downloads\\chromedrivernew\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("http://drive.google.com"); // opening google drive's site
}
public static void signIn() {
driver.findElement(By.linkText("Go to Drive")).click(); // clicking the "go to drive" button
System.out.print("Email: ");
String email = s.nextLine();
System.out.print("Password: ");
String pass = s.nextLine();
WebElement email_field = driver.findElement(By.id("identifierId"));
email_field.sendKeys(email);
}
public static void main(String[] args) {
launchBrowser();
System.out.println("Welcome to Google Drive! First, log into your Google Account.");
signIn();
}
}