Monday 29 December 2014

Few selenium webdriver exceptions


NoAlertPresentException - Occurs when Code exists to handle the alert, but there is no alert present in real time during execution. 
UnexpectedAlertPresentException - When there is a alert present which is not handled by the  code, this exception occurs. 
NoSuchElementException - When the Web element doesn't match with the element present in the browser or when the selenium tries to identify the specified element when its actually not  completed  loading the browser. 
NoSuchFrameException - Thrown when Code existsto handle a frame, but the frame didn't actually present execution. 
NoSuchWindowException- Occurs when Code exists to navigate to new window using driver.switchTo().window(session id) , but there is no window exists with the referenced window element. 
StaleElementReferenceException - Occurs when the refereed element is no more on DOM or the element has been deleted entirely by navigating to different page or refreshing the page. 
ElementNotVisibleException - This occurs when the element actually present in the DOM, however not visible or its in hidden to be referred.

Saturday 27 December 2014

Password field value entered twice on using selenium webdriver

While running webdriver script to login to webpage by provide the username and password credentials, you may notice that the password field is actually entered twice once you enter the username and then entering the password.

The reason is when you have logged in before via manually/script and if the auto save feature of user name and passwords are enabled and saved this may occur.

If Auto save feature is enabled for username and password, after entering the username via script and tabbing out to enter the password itself put the saved password.

Here the password is 7 characters, but 14 characters has been updated.

Password typed twice


Solution:

1. Remove the auto save of user name and password feature at browser level
2. Or do a clear on the fields before entering the values.
 

Thursday 25 December 2014

The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)

When using sendKeys on an web element using selenium, the reported exception may be thrown as below.

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)

    at scripts.VerifyLogin.main(VerifyLogin.java:12)


This can be corrected by changing the java compilation level tot he latest availabe verison in eclipse.
Project propeties > Build Path > configure Build Path > Java compiler > compiler compilation level (Change to latest available version).


   

Tuesday 23 December 2014

java was started but returned exit code=13

When you try to launch eclipse after installing, may end up with the "java was started but returned exit code=13"

Eclipse launch error

This could be due to the the version mismatch of eclipse or java or OS bit level.

Solution:

1. Try installing the same version (32 bit or 64 bit) of eclipse and java.
2. Make the eclipse to use the version of java you specify in 'eclipse.ini' file, which can be found in the root installation directory of eclipse (G:\eclipse) by adding 

-vm
C:\Program Files\Java\jdk1.8.0_11\bin\javaw.exe

above the -vmargs line in the file.
eclipse.ini


 This should solve the start up issue.

eclipse starts

Thursday 30 October 2014

Linking and Accessing files among two databases on Oracle, DB2 and MSSQL



Lets assume we have two databases as 'FIRST', 'SECOND' with 'first' and 'second' are the schema's for each databases and we have a table 'SECFILE' IN 'SECOND' database. So to access the 'SECFILE' from FIRST database we follow the below steps.

Oracle :

From First database (FIRST): Create database link from first database to connect to second database (SECOND)

SQL> CREATE PUBLIC DATABASE LINK ORALINK CONNECT TO second identified by second using 'SECOND';
Database link created.

From First database : Create the synonym for the table in second database as below.

SQL>  CREATE SYNONYM TESTF FOR SECFILE@ORALINK;
Synonym created.

Now we can access the table 'SECFILE' in 'SECOND' database from 'FIRST' database by referring the synonym name like

From First database:

desc TESTF;
select * from TESTF;


DB2:

Same way we can do in DB2 as below. Assuming same database names and tables,

From 'FIRST' database:

db2 => CREATE WRAPPER drda
DB20000I  The SQL command completed successfully.
db2 => CREATE SERVER DB2LINK TYPE DB2/UDB VERSION 10.1 WRAPPER DRDA AUTHORIZATION "second" PASSWORD "second123" OPTIONS (ADD NODE 'SECOND_N', ADD DBNAME 'SECOND')
DB20000I  The SQL command completed successfully.
db2 => CREATE USER MAPPING FOR SECOND SERVER DB2LINK OPTIONS (REMOTE_AUTHID 'second', REMOTE_PASSWORD 'second123')
DB20000I  The SQL command completed successfully.
db2 => CREATE NICKNAME TESTF FOR DB2LINK.second.SECFILE
DB20000I  The SQL command completed successfully.
db2 =>

From First database:

describe table TESTF;
select * from TESTF;


MSSQL :

Create a synonym for the table in 'SECOND' database as below.

CREATE SYNONYM TESTF FOR SECOND.second.SECFILE

Additionally need to provide privileges to 'first' of 'FIRST' database to access 'SECOND' database and back and fro.




















From First database:

select * from dbo.TESTF

Saturday 25 October 2014

Reclaim unused space in oracle datafiles


After dropping large number of tables or users the space occupied by tables/users will not be released in oracle.
As the allocation happened for the first time the space is occupied and it may be required in future, thus the space occupied remain reserved for future requirements.
The space occupied by data-files remain reserved unless an explicit way to resize has been performed.
One of the ways to reduce the data-file size is to know the free-size of the data-files, so as to reduce the data-file size based on the free-size.

SQL> select a.file_name,round(a.bytes/1024/1024) totalsize,b.freesize from dba_data_files a, (select file_id,round(sum(bytes/1024/1024)) freesize from dba_free_space group by file_id) b where a.file_id=b.file_id(+);
FILE_NAME
--------------------------------------------------------------------------------
 TOTALSIZE   FREESIZE
---------- ----------
/oracle/dbs/DBORA/system01.dbf
       800          1

/oracle/dbs/DBORA/DBORAINDEX.dbf
      6274       3283

/oracle/dbs/DBORA/sysaux01.dbf
       550         36


From the above result the freesize of the datafiles for the database are listed. The free-size is listed in MB, relating with that the data-file sizes can be resized as like below.

SQL> alter  database datafile '/oracle/dbs/DBORA/DBORAINDEX.dbf' RESIZE 5G;
Database altered.
SQL> select a.file_name,round(a.bytes/1024/1024) totalsize,b.freesize from dba_data_files a, (select file_id,round(sum(bytes/1
024/1024)) freesize from dba_free_space group by file_id) b where a.file_id=b.file_id(+);
FILE_NAME
--------------------------------------------------------------------------------
 TOTALSIZE   FREESIZE
---------- ----------
/oracle/dbs/DBORA/system01.dbf
       800          1
/oracle/dbs/DBORA/DBORAINDEX.dbf
      5120       2129
/oracle/dbs/DBORA/sysaux01.dbf
       550         36

Friday 24 October 2014

Oracle tables starts with BIN$


DROP table puts the tables in recycle bin, and it can be removed from recycle bin by using PURGE command.
The tables in recycle bin can be viewed by 'show recyclebin';

SQL> DROP TABLE RECYCLE;
Table dropped.
SQL> show recyclebin;
ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
RECYCLE          BIN$FGO4f+kYTnW0fc0rTXSvHQ==$0 TABLE        2014-09-12:19:11:48
SQL>
SQL> PURGE TABLE RECYCLE
  2  ;
Table purged.
SQL> show recyclebin;
SQL>

Detailed description can be found here

http://docs.oracle.com/cd/B19306_01/server.102/b14231/tables.htm#ADMIN01511

Thursday 9 October 2014

org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)


[TestNG] Running:
  C:\Users\tester\AppData\Local\Temp\testng-eclipse-520368244\testng-customsuite.xml

Started InternetExplorerDriver server (32-bit)
2.42.0.0
Listening on port 30903
FAILED CONFIGURATION: @BeforeMethod beforeMethod
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.69 seconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-06-10 19:27:58'


Driver info: org.openqa.selenium.ie.InternetExplorerDriver
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

.
.
.

The protected mode setting in internet explorer must be enabled for all zones listed under the security tab on Internet Options menu.
Correcting it to have the setting enables would solve the above reported issue.



Tuesday 7 October 2014

ORA-01119: error in creating database file


After dropping tablespace with including contents, may end up with "ORA-01119: error in creating database file".

Reasons could be
1. Not deleting the datafile with "INCLUDING CONTENTS AND DATAFILES"
2. Provided directory path does not exist
3. Error accessing the directory (read/write permission or misspelling of directory names)
4. Datafile already existing in the current directory


Here is the case with not deleting datafile with drop tablespace,

SQL> DROP TABLESPACE DATATS INCLUDING CONTENTS;
Tablespace dropped.


SQL> CREATE TABLESPACE DATATS LOGGING DATAFILE '/home/database/DATATS1.dbf' SIZE 1G AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
*
ERROR at line 1:
ORA-01119: error in creating database file
'/home/database/DATATS1.dbf'
ORA-27038: created file already exists
Additional information: 1


SQL> DROP TABLESPACE DATATS INCLUDING CONTENTS and datafiles;
DROP TABLESPACE DATATS INCLUDING CONTENTS and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'DATATS' does not exist


$ ls -lrt
total 63169492
-rw-r----- 1 oracle dbs   359723476 Oct  6 16:59 DATATS1.dbf
-rw-r----- 1 oracle dbs   863962592 Oct  6 23:03 temp01.dbf
-rw-r----- 1 oracle dbs   831239922 Oct  7 10:24 system01.dbf
-rw-r----- 1 oracle dbs   513430411 Oct  7 10:24 sysaux01.dbf
-rw-r----- 1 oracle dbs   108758112 Oct  7 10:24 redo03a.log
-rw-r----- 1 oracle dbs   104858342 Oct  7 10:24 redo02a.log
-rw-r----- 1 oracle dbs   222677423 Oct  7 10:24 INDEXTS1.dbf
.
.
.


$ rm -r DATATS1.dbf

SQL> CREATE TABLESPACE DATATS LOGGING DATAFILE '/home/database/DATATS1.dbf' SIZE 1G AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
Tablespace created.

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");

Wednesday 9 April 2014

Installing Jenkins in Unix/windows machine

1. Download jenkins.war file from http://jenkins-ci.org/ and upload it to the server

2. Execute the java web archive (Jenkins.war file) by running command

java –jar jenkins.war


3. The Jenkins server page can be viewed in browser on http://<server_ip>:<port_no>/



     After the server page is loaded


4. Now the Jenkins server is up and running. The new jobs and new nodes on which the jobs are designed to run should be set up.

Saturday 29 March 2014

Insert string with apostrophe(') in sql

when using Insert statement to inset string type fields and the values has an apostrophe('), how

the inset statements can be handled in such cases.


SQL> insert into donuts values('jelly's,9);
insert into donuts values('jelly's,9)
                                   *
ERROR at line 1:
ORA-00917: missing comma


SQL> insert into donuts values('jelly''s,9);
ERROR:
ORA-01756: quoted string not properly terminated

The Error displayed here is due to string data types that are delimited by the single quotation mark and the apostrophe(') is considered as the end of the string  delimiter.

The possible way is to escape single apostrophe (') with an extra apostrophe as below.


SQL> insert into donuts values('jelly''s',9);

1 row created.

Now the string with apostrophe is inserted into the table.

SQL> select * from donuts;


NAME PRICE
---------- ----------
jelly 9
jell's 9


Monday 24 March 2014

count tables for each user in oracle database

sql query to count no of tables owned by each user in oracle database


SELECT COUNT(*), owner  FROM ALL_TABLES group by owner;


SQL> SELECT COUNT(*), owner  FROM ALL_TABLES group by owner;
  COUNT(*) OWNER
---------- ------------------------------
        39 WIN
        39 REDON
      121 PANK
    3456 ANA
        32 MONK
        72 PAT
        93 GREF
    3456 CHIN
        10 KILM
        20 BLOG
      155 SYSTEM
   
11 rows selected.
 

Saturday 22 March 2014

Exception in thread "main" java.lang.AssertionError: Subclass must override this method


Exception in thread "main" java.lang.AssertionError: Subclass must override this method

   at java.lang.reflect.AccessibleObject.getAnnotation(libgcj.so.7rh)

   at org.kohsuke.args4j.ClassParser.parse(ClassParser.java:21)
   at org.kohsuke.args4j.CmdLineParser.<init>(CmdLineParser.java:91)
   at hudson.remoting.Launcher.main(Launcher.java:170)
To overcome this on launching slave.jar as part of jekins setup, try using latest java version.
This should be solved on using the latest java versions.