2

I have a little problem and I don't know why code does not work. I have element on site (window) which I want to resize (clicking on corner and pulling).

@Test
public void ResizeWindow()
{
    driver.get(URL); 
    WebElement resizeableWindow = driver.findElement(By.xpath("//*[@id='resizable']/div[3]"));
    Actions actions = new Actions(driver);
    actions.moveToElement(resizeableWindow);
    actions.clickAndHold(resizeableWindow);
    actions.moveByOffset(50,50);
}

But this piece of code does not want to resize window (code does not have problem with finding element). Any tips? Or hint on what should I change?

Guy
  • 46,488
  • 10
  • 44
  • 88
Szewniak
  • 69
  • 6

1 Answers1

3

You need to call perform() as last command to execute the previous commands

actions.perform();

The methods from Actions class return this, so you can chain them

Actions actions = new Actions(driver);
actions
    .moveToElement(resizeableWindow)
    .clickAndHold(resizeableWindow)
    .moveByOffset(50,50)
    .perform();
Guy
  • 46,488
  • 10
  • 44
  • 88