Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While creating a test script in selenium i am getting following error

package javaapplication3;
import java.lang.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
/**
 *
 * @author kipl74
 */
public class JavaApplication3 {

    /**
     * @param args the command line arguments
     */
    static WebDriver driver = new FirefoxDriver();
    public static void main(String[] args) {
        // TODO code application logic here
        String baseurl="www.google.com";

        driver.get(baseurl);

    }
}

When I run this code, I am getting following errors. How to resolve it?

Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Command duration or timeout: 16 milliseconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'comp74', ip: '192.168.0.74', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_17'
Session ID: 0282db64-b28b-4c3b-ba83-26fe06bd46a3
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=26.0}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)
    at javaapplication3.JavaApplication3.main(JavaApplication3.java:23)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: f.QueryInterface is not a function
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'comp74', ip: '192.168.0.74', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_17'
Driver info: driver.version: unknown
    at <anonymous class>.FirefoxDriver.prototype.get(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/[email protected]/components/driver_component.js:8720)
    at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/[email protected]/components/command_processor.js:10831)
    at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/[email protected]/components/command_processor.js:10836)
    at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/[email protected]/components/command_processor.js:10778)
Java Result: 1
like image 254
Naveen Chhaniwal Avatar asked Jan 28 '14 09:01

Naveen Chhaniwal


People also ask

How do I fix common errors in Selenium?

The Solution To fix this problem, you need to make the element visible. Specifically, Selenium tries to click on the exact center of the element. Your options are to scroll up, or hover over an element to close it, or minimize an expanded element. Simply put, make sure that your element is visible for clicking.

What are Selenium WebDriver errors?

Any WebDriver command that is sent to might plausibly receive an error response. An error is represented by an HTTP response with an HTTP status code in the 4xx or 5xx range, and a JSON payload holding details of the error.

Why is Selenium not working?

This is because you don't have the Chromedriver. Go to the ChromeDriver [downloads page] (https://chromedriver.chromium.org/downloads). Download the correct version as per your browser version. As an argument,pass executable_path=r'path/to/chromedriver.exe' in driver = webdriver.


1 Answers

Method get requires the protocol as part of the URL.

Change:

String baseurl = "www.google.com";

To:

String baseurl = "http://www.google.com";
like image 62
barak manos Avatar answered Jan 04 '23 06:01

barak manos