2

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"));


    }

}
1
  • Change the name of class it causes ambiguity when you access or try to import the WebElement for locating your element Commented Sep 26, 2017 at 9:16

2 Answers 2

4

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

Pick a different name for your class.

1
  • 1
    In addition, just for good Java purposes, don't import org.openqa.selenium.*; Instead, explicitly import only the elements you need.
    – corsiKa
    Commented Sep 21, 2017 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 and acknowledge you have read our privacy policy.

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