Monday, 1 September 2014

Exception in thread "main" java.lang.IllegalStateException

When executing a selenium script written in java to use IE/Chrome driver, an exception would have been thrown to check System.setProperty. The code below seems to be exactly right but 'webdriver' is coded as 'Webdriver' in the first argument, and there stands the exception.

File file = new File("G:\\Data\\git\\Test\\lib\\IEDriverServer.exe");
System.setProperty("Webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();


Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html

Tuesday, 15 July 2014

using BETWEEN Operator with Integer and Text Value

BETWEEN operator in SQL selects values within a range. The values can be numbers or text.

SQL> Select * from boys;

    BOY_ID BOY                      TOY_ID DEPT
---------- -------------------- ---------- --------------------
         1 Jana                          3 elec
         6 Sam                           8 aero
         2 Giri                          3 csc
         4 Giri                          7 csc
 

BETWEEN operator on integer values are selected as below

SQL> Select * from boys where TOY_ID BETWEEN 1 AND 7;

    BOY_ID BOY                      TOY_ID DEPT
---------- -------------------- ---------- --------------------
         1 Jana                          3 elec
         2 Mess                          3 csc
         4 Mess                          7 csc

On using text value with BETWEEN operator, the text value is compared against the column values and result set is produced.
In this example the boy 'Sam' is not selected as 'Sam' is  > 'S'. (i.e. Same > Sam > S)

SQL> Select * from boys where boy BETWEEN 'J' AND 'S';

    BOY_ID BOY                      TOY_ID DEPT
---------- -------------------- ---------- --------------------
         1 Jana                          3 elec
         2 Mess                          3 csc
         4 Mess                          7 csc

On using full text 'Sam' on BETWEEN operator, the row holding column value 'Sam' 'is selected.

SQL> Select * from boys where boy BETWEEN 'J' AND 'Sam';

    BOY_ID BOY                      TOY_ID DEPT
---------- -------------------- ---------- --------------------
         1 Jana                          3 elec
         6 Sam                           8 aero
         2 Mess                          3 csc
         4 Mess                          7 csc






 

write a HYPERLINK into excel using jxl

HYPERLINK's can be written into excel using java using jxl. This will be useful to add screenshots of the web pages captured on running automated test cases through selenium

String scn = "HYPERLINK(\"D:\\snaps\\"+step_num+".jpg\",\"Click\")";
Formula link = new Formula(3,0,scn);
wws.addCell(link);


Monday, 5 May 2014

Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function

While running java class file for selenium webdriver facing with the issue as below:

Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Command duration or timeout: 30 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'rgfr12321', ip: '104.43.244.18', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_45'
Session ID: 7afc8ea4-c911-4da7-a435-5f34622ca096
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=28.0}]
 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.get(RemoteWebDriver.java:300)
 at sample.Gmail.main(Gmail.java:14)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: f.QueryInterface is not a function
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'rgfr12321', ip: '104.43.244.18', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: unknown


This can be corrected by having the pull path of the url as below


Change:
WebDriver driver = new FirefoxDriver();
driver.get("www.gmail.com");

To:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.gmail.com");