在类中找不到主要方法首先,请将main方法定义为:public static void main(String [] args)

时间:2015-08-22 02:36:17

标签: selenium

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


 public class First {

    public static void main(String[] args)
    {
        WebDriver driver=new FirefoxDriver();
        driver.get("www.facebook.com");
        driver.manage().window().maximize();
    }

}

I am getting this error when I am trying to run it in Eclipse Kepler:

线程“main”中的异常org.openqa.selenium.WebDriverException:f.QueryInterface不是函数 命令持续时间或超时:18毫秒 构建信息:版本:'2.46.0',修订版:'87c69e2',时间:'2015-06-04 16:17:10' 系统信息:主机:'Jyoti-PC',ip:'192.168.112.1',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8 .0_40' 驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver Capabilities [{applicationCacheEnabled = true,rotate = false,handlesAlerts = true,databaseEnabled = true,version = 37.0.1,platform = WINDOWS,nativeEvents = false,acceptSslCerts = true,webStorageEnabled = true,locationContextEnabled = true,browserName = firefox,takesScreenshot = true,javascriptEnabled = true,cssSelectorsEnabled = true}] 会话ID:a35eb217-b3b2-4de8-abc2-4e72ceb06916     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)     at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)     at java.lang.reflect.Constructor.newInstance(Unknown Source)     在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)     在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)     在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)     在org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:306)     at first.main(first.java:10) 引起:org.openqa.selenium.WebDriverException:f.QueryInterface不是函数 构建信息:版本:'2.46.0',修订版:'87c69e2',时间:'2015-06-04 16:17:10' 系统信息:主机:'Jyoti-PC',ip:'192.168.112.1',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8 .0_40' 驱动程序信息:driver.version:未知     at .FirefoxDriver.prototype.get(file:/// C:/Users/Jyoti/AppData/Local/Temp/anonymous573077067589922398webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10160)     at .DelayedCommand.prototype.executeInternal_ / h(file:/// C:/Users/Jyoti/AppData/Local/Temp/anonymous573077067589922398webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12282)     at .DelayedCommand.prototype.executeInternal_(file:/// C:/Users/Jyoti/AppData/Local/Temp/anonymous573077067589922398webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12287)     at .DelayedCommand.prototype.execute /<(file:/// C:/Users/Jyoti/AppData/Local/Temp/anonymous573077067589922398webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12229 )

1 个答案:

答案 0 :(得分:0)

线程“main”org.openqa.selenium中的异常。 WebDriverException:f.QueryInterface不是函数

发生此异常是因为您尝试获取()一个没有以http://或https://

为前缀的URL
driver.get("https://www.facebook.com");