Monday 27 January 2014

Verification points in Selenium ...

1.    To check Element Present:
if(driver.findElements(By.xpath("value")).size() != 0){
System.out.println("Element is Present");
}else{
System.out.println("Element is Absent");
}
Or
if(driver.findElement(By.xpath("value"))!= null){
System.out.println("Element is Present");
}else{
System.out.println("Element is Absent");
}
2.    To check Visible:
if( driver.findElement(By.cssSelector("a > font")).isDisplayed()){
System.out.println("Element is Visible");
}else{
System.out.println("Element is InVisible");
}
3.    To check Enable:
if( driver.findElement(By.cssSelector("a > font")).isEnabled()){
System.out.println("Element is Enable");
}else{
System.out.println("Element is Disabled");
}
4.    To check text present:
if(driver.getPageSource().contains("Text to check")){
System.out.println("Text is present");
}else{
System.out.println("Text is absent")


Thursday 2 January 2014

Select methods in selenium Webdriver...

Select Methods
The following are the most common methods used on drop-down elements.

selectByVisibleText() :
deselectByVisibleText():

Selects/deselects the option that displays the text matching the parameter.
Parameter: The exactly displayed text of a particular option

selectByValue()
deselectByValue()

Selects/deselects the option whose “value” attribute matches the specified parameter.
Parameter: value of the “value” attribute remember that not all drop-down options have the same text and “value”, like in the example below.

selectByIndex()
deselectByValue()


Selects/deselects the option at the given index.
Parameter: the index of the option to be selected


isMultiple()

Returns TRUE if the drop-down element allows multiple selections at a time; FALSE if otherwise.
Needs parameters needed

deselectAll ():


Clears all selected entries. This is only valid when the drop-down element supports multiple selections.

No parameters needed

Navigate commands in Selenium Webdriver...


Navigate commands:
 These commands allow you to refresh go-into and switch back and forth between different webpages.

navigate ().to() :        It automatically opens a new browser window and fetches the
                                 page that  you specify inside its parentheses.

                                It does exactly the same thing as the get() method.

navigate().refresh() : It refreshes the current page


navigate().back():       Takes you back by one page on the browser’s history.

navigate().forward():  Takes you forward by one page on the browser’s history.