8protons 8protons - 29 days ago 6
Java Question

Why does the Selenium IDE import .* and .SpecificType?

When you export a Selenium IDE test to Java, the code imports a ton of packages. Why does it automatically put in the code:

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

This was on a very basic test that I exported from the IDE to Java. Why automatically include specific packages like
if you're going to import the whole
package anyways?


Looks like you want to know about java imports. Asterisk, i.e. * will import all the TYPES, i.e classes, interfaces etc in the package which precedes it, i.e. selenium. It does NOT get all the types in its sub-packages. Refer - https://docs.oracle.com/javase/tutorial/java/package/usepkgs.html

Now you know why this code won't compile.

import org.openqa.selenium.*;
//import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.support.ui.Select;

public class Temp {
    public static void main(String [] args){
        WebDriver driver = new FirefoxDriver();