首页 文章

在eclipse for selenium程序中,在类驱动程序中找不到Error-main方法

提问于
浏览
0

我正在日食中学习硒但是出现以下错误 -

错误:在类驱动程序中找不到主方法,请将main方法定义为:public static void main(String [] args)或JavaFX应用程序类必须扩展javafx.application.Application

我已经在buildpath中添加了selenium jar和selenium standalone jar文件但是错误仍然存在,这是代码

import org.apache.xpath.operations.String;
 import org.openqa.selenium.firefox.FirefoxDriver;


   public class driver{

   public static void main(String[] args)
    {
        new FirefoxDriver();

    }
    }

我彻底搜索,但无法找到解决方案,请帮忙

1 回答

  • 1

    问题在于您的导入,您不应该使用:

    import org.apache.xpath.operations.String;
    

    通过执行此操作,您将使编译器使用“org.apache.xpath.operations.String”而不是正常的“java.lang.String”如果删除此导入,它将正常工作 .

    import org.openqa.selenium.firefox.FirefoxDriver;
    
    public class App {
        public static void main(String[] args) {
            new FirefoxDriver();
        }
    }
    

相关问题