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