The blog gives you idea of testing and automation testing example of selenium webdriver,SQl and Jmeter, you see the basic example of selenium web driver and get idea how to do automation testing,

How to Verify Checked & Unchecked of check-Box Using selenium Webdriver

Checkbox are an often used element in the web application, But how do you work with them in selenium web driver or automation testing.
I am doing an automation testing of one application and I am facing one scenario to verify Check-box are checked or not using automation code

Solution :
There are two ways to approach this first one check if an element has a checked attribute or not, Checked attribute you can check in fire-bug for particular checkbox(a.k.a. performing an attribute lookup), another one by asking an element has been selected or not, you can check selected or isselected using webdriver inbuilt method


Below is CSS code to verify checked and unchecked attribute:


  unchecked
  checked

Java Code :

public void VerifyChkbox(WebElement chkbox){
boolean checkstatus;
checkstatus=chkbox.isSelected();
if (checkstatus==true){
System.out.println("Checkbox is already checked");  
       }
else
     {
chkbx1.click();
System.out.println("Checked the checkbox");
     }
}

Same code is applicable for unchecked


Perform Drag-and-Drop operation

If you want to drag and drop some element in Automation testing then you should have to use action class. Action class Supports all user interactions Example : Mouse and Keyboard event on a web page or application

You have to find Xpath of elements, first which element you want to drag and second where you want to drop.

WebDriver driver = new FirrfoxDriver();
// Element which you want to drag
WebElement elementToDrag = driver.findElement(By.id("elementToDrag"));
// element at which position you want to drop
WebElement elementToDropAt = driver.findElement(By.id("placeWhereDrag"));

Actions action = new Actions(driver);
action.dragAndDrop(elementToDrag, elementToDropAt).perform();


dragAndDrop method is in the actions class which takes two parameters as input. One is the element to drag and another one is the destination to drop element.
after execution of above code you element will be drap from one position to another position.
Powered by Blogger.