org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
- khyati sehgal
- Jun 18, 2014
- 2 min read
org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Command duration or timeout: 17 milliseconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'ksehgal', ip: '192.168.0.95', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_43'
Session ID: b469c4b9-7596-4b66-b87e-646db4256726
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=29.0.1, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 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:595) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:300)
Problem Statement
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class WebSiteTest {
WebDriver driver = null;
@Before
public void startDriver() {
System.setProperty("webdriver.chrome.driver",
"F://Selenium//chromedriver_win32//chromedriver.exe");
driver = new ChromeDriver();
driver.get("www.yahoo.com");
@Test
public void getWebSite() {
// place some code here
}
@After
public void killSession() {
driver.close();
}}
The problem
driver.get("www.yahoo.com");
this line of code doesnot have http:// attached before the URL ,so user needs to add this explicitly in chrome as chrome only processes the URL as is unlike other browsers.
Resolution
You can actually change the code as I did below to get rid of issues like this. You need to give full URL in the get function of Selenium, I tried it and it worked for me.
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class WebSiteTest {
WebDriver driver = null;
@Before
public void startDriver() {
System.setProperty("webdriver.chrome.driver",
"F://Selenium//chromedriver_win32//chromedriver.exe");
driver = new ChromeDriver();
driver.get(" http://www.yahoo.com ") // You need to add http earlier it was "www.yahoo.com"
}
@Test
public void getWebSite() {
// place some code here
}
@After
public void killSession() {
driver.close();
}}
Remarks
No bug is small or big, it depends on the viewpoint you are carrying while evaluating the same 🙂
Comments