【问题标题】:In eclipse for selenium program , Error- main method not found in class driver在 eclipse for selenium 程序中,在类驱动程序中找不到错误-main 方法
【发布时间】:2016-03-07 02:10:39
【问题描述】:

我在 Eclipse 中学习硒,但出现以下错误-

错误:在类驱动中找不到主方法,请将主方法定义为: 公共静态无效主要(字符串 [] 参数) 或者 JavaFX 应用程序类必须扩展 javafx.application.Application

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

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


   public class driver{

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

    }
    }

我彻底搜索了,但找不到解决方案,请帮助

【问题讨论】:

    标签: java eclipse selenium selenium-webdriver


    【解决方案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();
        }
    }
    

    【讨论】:

    • 它可以工作,谢谢 thebobblob 我该如何调试这些问题
    猜你喜欢
    • 2018-02-27
    • 2020-04-16
    • 1970-01-01
    • 1970-01-01
    • 2011-04-12
    • 2021-10-24
    • 2014-10-26
    • 1970-01-01
    • 2022-01-28
    相关资源
    最近更新 更多