Saturday, August 29, 2015

Webdriver Exceptions

Exceptions (selenium.common.exceptions.)

Description

ElementNotSelectableException

Thrown when trying to select an unselectable element

ElementNotVisibleException

Thrown when an element is present on the DOM, but it is not visible, and so is not able to be interacted with.

ErrorInResponseException

Thrown when an error has occurred on the server side

ImeActivationFailedException

Thrown when activating an IME engine has failed.

ImeNotAvailableException

Thrown when IME support is not available. This exception is thrown for every IME-related method call if IME support is not available on the machine.

InvalidCookieDomainException

Thrown when attempting to add a cookie under a different domain than the current URL.

InvalidElementStateException

 

InvalidSelectorException

Thrown when the selector which is used to find an element does not return a WebElement. Currently this only happens when the selector is an xpath expression and it is either syntactically invalid (i.e. it is not a xpath expression) or the expression does not select WebElements (e.g. “count(//input)”).

InvalidSwitchToTargetException

Thrown when frame or window target to be switched doesn’t exist.

MoveTargetOutOfBoundsException

Thrown when the target provided to the ActionsChains move() method is invalid, i.e. out of document.

NoAlertPresentException

Thrown when switching to no presented alert.

NoSuchAttributeException

Thrown when the attribute of element could not be found.

NoSuchElementException

Thrown when element could not be found.

NoSuchFrameException

Thrown when frame target to be switched doesn’t exist.

NoSuchWindowException

Thrown when window target to be switched doesn’t exist.

RemoteDriverServerException

 

StaleElementReferenceException

Thrown when a reference to an element is now “stale”.
Stale means the element no longer appears on the DOM of the page.

TimeoutException

Thrown when a command does not complete in enough time.

UnableToSetCookieException

Thrown when a driver fails to set a cookie.

UnexpectedAlertPresentException

Thrown when an unexpected alert is appeared.

UnexpectedTagNameException

Thrown when a support class did not get an expected web element.

WebDriverException

Base webdriver exception.

 

 

 

Friday, August 28, 2015

MoveZeroes to END - Java


public class MoveZeroes {

public static void main(String a[]) {
int[] intArray = { 1, 0, 9, 7, 6, 0, 2, 0, 7, 0, 0 };
moveZerosToEnd(intArray);
}

private static void moveZerosToEnd(int[] i) {

int counter = 0;
int[] temp = new int[i.length];
for (int k = 0; k < i.length; k++) {
if (i[k] != 0) {
temp[counter++] = i[k];
}
}
while (counter < i.length) {
temp[counter] = 0;
counter++;
}
for (int j : temp) {
System.out.println(j);
}
}
}

Agile Information



Agile development model is also a type of Incremental model. Software is developed in incremental, rapid cycles. This results in small incremental releases with each release building on previous functionality. Each release is thoroughly tested to ensure software quality is maintained. It is used for time critical applications.  Extreme Programming (XP) is currently one of the most well-known agile development life cycle model.
Advantages of Agile model:
§  Customer satisfaction by rapid, continuous delivery of useful software.
§  People and interactions are emphasized rather than process and tools. Customers, developers and testers constantly interact with each other.
§  Working software is delivered frequently (weeks rather than months).
§  Face-to-face conversation is the best form of communication.
§  Close, daily cooperation between business people and developers.
§  Continuous attention to technical excellence and good design.
§  Regular adaptation to changing circumstances.
§  Even late changes in requirements are welcomed

Disadvantages of Agile model:
§  In case of some software deliverables, especially the large ones, it is difficult to assess the effort required at the beginning of the software development life cycle.
§  There is lack of emphasis on necessary designing and documentation.
§  The project can easily get taken off track if the customer representative is not clear what final outcome that they want.
§  Only senior programmers are capable of taking the kind of decisions required during the development process. Hence it has no place for newbie programmers, unless combined with experienced resources.

When to use Agile model:
§  When new changes are needed to be implemented. The freedom agile gives to change is very important. New changes can be implemented at very little cost because of the frequency of new increments that are produced.
§  To implement a new feature the developers need to lose only the work of a few days, or even only hours, to roll back and implement it.
§  Unlike the waterfall model in agile model very limited planning is required to get started with the project. Agile assumes that the end users’ needs are ever changing in a dynamic business and IT world. Changes can be discussed and features can be newly effected or removed based on feedback. This effectively gives the customer the finished system they want or need.

String Reverse using Java - Recursive & Non - Recursive



public class StringReverse {

public static void main(String a[]) {

StringReverse myStringReverse = new StringReverse();
String myString = "reverse";
System.out.println("String reverse of given string " + myString + " using non-recursion is ---> "
+ myStringReverse.reverseNonrecursion(myString));
System.out.println("String reverse of given string " + myString + " using recursion is ---> "
+ myStringReverse.reverseRecursion(myString));
}

private String reverseRecursion(String myString) {
String temp = "";
if (myString.length() == 1) {
return myString;
} else {
temp = myString.charAt(myString.length() - 1)
+ reverseRecursion(myString.substring(0, myString.length() - 1));
return temp;
}
}

private String reverseNonrecursion(String myString) {
char[] myCharArray = myString.toCharArray();
String temp = "";
for (int i = 0; i < myCharArray.length; i++)
temp = myCharArray[i] + temp;
return temp;
}

}