Delivered by FeedBurner

Resizing JQuery Resizable Element Using Selenium WebDriver

I have provided different examples of how to deal with J Query elements using selenium WebDriver like Drag and drop element using dragAndDrop methodDrag and drop element using dragAndDropBy method, Selecting multiple Items using clickAndHold method, Moving slider using clickAndHold and moveByOffset method. To perform all these actions/operations, We have used different methods of selenium webdriver advanced user Interactions API class Actions.

Now let me give you one more related example where you wants to resize JQuery rezizable element. To perform this operation, First we have to locate bottom-right side corner of resizable element and then we can move that corner by specific offset In X-Y directions.

package Testing_Pack;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class ResizeElement {
WebDriver driver = null;
    public void setup() throws Exception {  
  driver = new FirefoxDriver();
         driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
 public void selectItems() throws InterruptedException {  
  //Locate resizable element's bottom-right corner.
  WebElement resizeElement = driver.findElement(By.xpath("//div[@id='resizable']/div[3]"));  
  //To resize jQuery resizable element by 250 pixel X,Y offset using dragAndDropBy method of Actions class.
  new Actions(driver).dragAndDropBy(resizeElement, 250, 250).build().perform();
  //After 5 seconds, This will resize jQuery resizable element by -100 pixel X,Y offset using the combination of clickAndHold, moveByOffset and release methods of Actions class.
  new Actions(driver).clickAndHold(resizeElement).moveByOffset(-100,-100).release().perform();


You can use single method dragAndDropBy or combination of clickAndHold and moveByOffset methods to perform this operation as shown In above example. You can directly run It In your eclipse and verify the result.

1 comment:

  1. I can not perform Actions class on both MAC and Window. The test report shows me test case PASS but it did not perform on webpage. Have you ever face this problem and could you help me solve it?