Main method not found in class First, please define the main method as: public static void main(String[] args) - 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:
Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Command duration or timeout: 18 milliseconds
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: '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 info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=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}]
Session 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)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:306)
at first.main(first.java:10)
Caused by: org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: '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 info: driver.version: unknown
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)

Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
This exception happens because you are trying to get() a URL that's not prefixed with http:// or https://
driver.get("https://www.facebook.com");

Related

Unable to run selenium with IE browser via Jenkins

Selenium version 3.5
IEDriverserver - 3.5.0
IE version - 11
Jenkins version 2.75
private static final WebDriver WebDriverRefrence = null;{
}
public WebDriver driver ;
#BeforeTest
public void launchBrowser() {
Logger.getRootLogger().setLevel(Level.OFF);
System.setProperty("webdriver.ie.driver","C:\\AUTOMATION\\IEDriverServer.exe");
//Turn ON Protected Mode for the IE Browser
DesiredCapabilities aots = DesiredCapabilities.internetExplorer();
aots.setCapability("nativeEvents",false);
aots.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
driver = new InternetExplorerDriver(aots)
driver.get("https://www.gmail.com");
}
#Test
public void Test_case_001() throws InterruptedException {
driver.findElement(By.id("identifierId")).sendKeys("abc");
Thread.sleep(1000);
driver.findElement(By.xpath(".//*[#id='identifierNext']/div[2]")).click();
Thread.sleep(3000);
driver.findElement(By.xpath(".//*[#id='password']/div[1]/div/div[1]/input")).sendKeys("XXXXXX");
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[#id='passwordNext']/div[2]")).click();
}
}
I have a simple Selenium code to login to Gmail.
I'm able to run successfully from eclipse (IE browser)
I'm able to run successfully from eclipse (FF browser)
I'm able to run successfully via Jenkins (FF browser)
But when I use IE browser and run via Jenkins, it fails.
The code and error is below. Don't know why element is not found when running via Jenkins.
Here is the error from testing output file :
-<test-method finished-at="2017-09-06T13:47:33Z" started-at="2017-09-06T13:47:26Z" duration-ms="6405" name="Test_case_001" signature="Test_case_001()[pri:0, instance:test2.practice#4c75cab9]" status="FAIL">
-<exception class="org.openqa.selenium.NoSuchElementException">
-<message>
-<![CDATA[Unable to find element with xpath == .//*[#id='password']/div[1]/div/div[1]/input
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'DESKTOP-E0D9KLG', ip: '135.70.196.248', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0.0, ie.ensureCleanSession=false, elementScrollBehavior=0.0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:43511/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000.0, ignoreProtectedModeSettings=true}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, javascriptEnabled=true, platformName=windows, setWindowRect=true, platform=ANY}]
Session ID: 1baa5458-8f37-4e13-9119-08b88aba17f0
*** Element info: {Using=xpath, value=.//*[#id='password']/div[1]/div/div[1]/input}]]>
</message>
-<full-stacktrace>
-<![CDATA[org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == .//*[#id='password']/div[1]/div/div[1]/input
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'DESKTOP-E0D9KLG', ip: '135.70.196.248', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0.0, ie.ensureCleanSession=false, elementScrollBehavior=0.0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:43511/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000.0, ignoreProtectedModeSettings=true}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, javascriptEnabled=true, platformName=windows, setWindowRect=true, platform=ANY}]
Session ID: 1baa5458-8f37-4e13-9119-08b88aba17f0
*** Element info: {Using=xpath, value=.//*[#id='password']/div[1]/div/div[1]/input}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:414)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:513)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:406)
at test2.practice.Test_case_001(practice.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.TestNG.privateMain(TestNG.java:1355)
at org.testng.TestNG.main(TestNG.java:1324)

How to safely update chromedriver on selenium nodes

I have a selenium grid setup with one hub and 5 nodes. they both use the same version of selenium server 2.41.0.
On the nodes there are already chromedriver setup in the same folder as selenium sever.
Now the task is to update the chromedriver without broken any existing jenkins tests.
I have tried manually go to each nodes and update the chromedriver file. But, the tests on jenkins will throw WebDriverException saying unable to create driver.
What could be the issue here?
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'dseleniumnode05.xxx-dev.com', ip: 'xx.xx.xx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.10-100.fc18.x86_64', java.version: '1.7.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
14:08:37.077 INFO - Executing: [new session: Capabilities [{platform=LINUX, browserName=chrome, proxy={socksUsername=null, noProxy=null, httpProxy=proxy.xxx-stage.com:80, socksPassword=null, ftpProxy=null, sslProxy=proxy.xxx-stage.com:443, proxyAutoconfigUrl=null, proxyType=MANUAL, class=org.openqa.selenium.Proxy, autodetect=false, hCode=1182650898, socksProxy=null}, version=, chrome.switches=[--start-maximized]}]] at URL: /session)
14:08:37.078 INFO - Creating a new session for Capabilities [{platform=LINUX, browserName=chrome, proxy={socksUsername=null, noProxy=null, httpProxy=proxy.xxx-stage.com:80, socksPassword=null, ftpProxy=null, sslProxy=proxy.xxx-stage.com:443, proxyAutoconfigUrl=null, proxyType=MANUAL, class=org.openqa.selenium.Proxy, autodetect=false, hCode=1182650898, socksProxy=null}, version=, chrome.switches=[--start-maximized]}]
Starting ChromeDriver (v2.10.267518) on port 13326
Only local connections are allowed.
[0.500][WARNING]: PAC support disabled because there is no system implementation
14:09:38.101 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'dseleniumnode05.xxx-dev.com', ip: 'xx.xx.xx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.10-100.fc18.x86_64', java.version: '1.7.0_45'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:177)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:113)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:90)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:96)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:63)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:202)
at org.openqa.selenium.remote.server.JsonHttpRemoteConfig.handleRequest(JsonHttpRemoteConfig.java:193)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:174)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:140)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'dseleniumnode05.xxx-dev.com', ip: 'xx.xx.xx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.10-100.fc18.x86_64', java.version: '1.7.0_45'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:72)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:56)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:216)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:170)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.reflect.InvocationTargetException
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:526)
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:62)
... 8 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.10.267518,platform=Linux 3.11.10-100.fc18.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.52 seconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'dseleniumnode05.xxx-dev.com', ip: 'xx.xx.xx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.10-100.fc18.x86_64', java.version: '1.7.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
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:526)
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.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.chrome.ChromeDriver.startSession(ChromeDriver.java:181)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:160)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:128)
... 13 more
14:09:38.103 WARN - Exception: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.10.267518,platform=Linux 3.11.10-100.fc18.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.52 seconds
the matter is that instance of driver is created on host machine (using existing chromdriver file there). Obviously once you substitute updated chrome driver file (of a newer version) older one -> everything should work fine after driver instance reinitizalization.
To initialize driver , I'm using following java piece of code:
public static WebDriver driverSetUp(WebDriver driver) throws MalformedURLException {
DesiredCapabilities capability = DesiredCapabilities.chrome();
log.info("Google chrome is selected");
System.setProperty("webdriver.chrome.driver", "....path/chromedriver.exe");
capability.setBrowserName("chrome");
capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
String webDriverURL = "http://" + environmentData.getHubIP() + ":" + environmentData.getHubPort() + "/wd/hub";
driver = new RemoteWebDriver(new URL(webDriverURL), capability);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(1920, 1080));
return driver;
}
Try it out and let us know whether issue persists. Thanks.

On perfect HTML, WebDriver gives a NoSuchElementException on the controls

I was trying to automate the Reset functionality in "http://www.efrotech.com/careers" for learning purposes. When I get the control locators I see it is perfect HTML that has almost all the locators; but when I try to run the script it is not recognizing the control and throwing painful NoSuchElement exception. Can you suggest what could be going wrong in that?
package com;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class ScriptChecker {
/**
* #param args
*/
public static WebDriver driver;
public static String baseUrl;
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
baseUrl = "http://www.efrotech.com";
driver.get(baseUrl +"/careers");
new Select(driver.findElement(By.id("ddlJobs"))).selectByVisibleText("QA Engineer");
driver.findElement(By.cssSelector("input#txtName")).sendKeys("Muzaffar");
System.out.println("Done here");
}
}
I have tried every locator but unable to manipulate the control state and its values.
Stacktrace followed:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"ddlJobs"}
Command duration or timeout: 10.07 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'muzaffar', ip: '192.168.0.161', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_05'
Session ID: 206431fe-6770-4cbc-a60e-71fe92739807
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=25.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(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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.findElement(RemoteWebDriver.java:348)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:389)
at org.openqa.selenium.By$ById.findElement(By.java:214)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:340)
at com.ScriptChecker.main(ScriptChecker.java:30)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"id","selector":"ddlJobs"}
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'muzaffar', ip: '192.168.0.161', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_05'
Driver info: driver.version: unknown
at .FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/SMUZAF~1/AppData/Local/Temp/anonymous1906408348495286600webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js:8905)
at .fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/SMUZAF~1/AppData/Local/Temp/anonymous1906408348495286600webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js:396)
The drop down element which you are trying to use is under iFrames. Please switch to it and then proceed with your selection.
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[height='520']")));
new Select(driver.findElement(By.xpath(".//*[#id='ddlJobs']"))).selectByVisibleText("QA Engineer");
hope this solves.

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/fxdriver#googlecode.com/components/driver_component.js:8720)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10831)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10836)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10778)
Java Result: 1
Method get requires the protocol as part of the URL.
Change:
String baseurl = "www.google.com";
To:
String baseurl = "http://www.google.com";
Please check your calling method to open the browser. I believe you have written code like this:
driver.get("Url"); //Incorrect Code
Correct should be like:
driver.get(Url);// Correct Code

Query related to Explicit wait: wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(

package wait1;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Explicit {
public static void main(String[] args) {
FirefoxDriver driver= new FirefoxDriver();
WebDriverWait wait= new WebDriverWait(driver,20 );
driver.get("http://www.91mobiles.com/");
driver.findElement(By.xpath("//*[#id='q']")).sendKeys("Micromax");
//wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[#id='ui-id-22']/span[2]")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id=ui-id-172")));
driver.findElement(By.xpath("//*[#id='ui-id-52']")).click();
}
}
I am getting the following error when I execute the above script:
Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 20 seconds waiting for visibility of element located by By.id: id=ui-id-172
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
at wait1.Explicit.main(Explicit.java:20)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"id=ui-id-172"}
Command duration or timeout: 21 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Session ID: fd977506-2457-4981-a304-f9a9b6b57f4e
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=17.0.7}]
at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
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.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:348)
at org.openqa.selenium.By$ById.findElement(By.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:522)
at org.openqa.selenium.support.ui.ExpectedConditions.access$0(ExpectedConditions.java:520)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:130)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
... 1 more
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"id","selector":"id=ui-id-172"}
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Driver info: driver.version: unknown
The behavior you are getting is the expected bahavior. You specified a 20 second explicit wait and in that time the ExpectedConditions.visibilityOfElementLocated(...) could not be established. So the wait fails with a timeout.
If you want to go on in your program you need to surround the wait in a try-catch block and catch org.openqa.selenium.TimeoutException
Try using like this
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[#id='ui-id-52']"));
Make sure that whatever identification type you use while waiting should be in the statement you use for action. (e.g. click, set etc.)
Here, we have two solutions...
Try increasing your WebDriverWait time to check if it fix the issue.
Try to locate same element by firebug, if it is successfully found by firebug, than WebDriverWait time is the only culprit.
You'll always get a timeout with the code you have. This is the offending line:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id=ui-id-172")));
Note how you have By.id("id=ui-id-172"). This is wrong. It would look for an object that has the id id=ui-id-172. While it is possible to have an id with this value (yes, I tried and it works) it is unlikely that this is what you want, especially given your XPath expression on the next line. What you want, to be consistent with the rest of your code, is By.id("ui-id-172").