1

I am getting:

Type mismatch: cannot convert from org.openqa.selenium.WebElement to WebElement

for the below code:

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class WebElement {

    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.manage().window().maximize();

        driver.get("https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin");

        WebElement emailField = driver.findElement(By.id("identifierId"));


    }

}
  • Change the name of class it causes ambiguity when you access or try to import the WebElement for locating your element – iamsankalp89 Sep 26 '17 at 9:16
4

By naming your class WebElement, you are shadowing the imported WebElement.

Pick a different name for your class.

  • 1
    In addition, just for good Java purposes, don't import org.openqa.selenium.*; Instead, explicitly import only the elements you need. – corsiKa Sep 21 '17 at 19:26
0

Change the name of class it causes ambiguity when you access or try to import the WebElement for locating your element

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.