Both functions works great on its own. But when I put them together. After I drag and drop the first element, I can't drag and drop the same element in the empty table.
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class practice {
private WebDriver driver;
private String baseUrl;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "website link";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testUntitled3() throws Exception {
driver.get(baseUrl );
//drag and drop first element
driver.findElement(By.xpath("xpath for tab 1")).click();
WebElement drag1 = driver.findElement(By.xpath("element in tab 1"));
WebElement drop= driver.findElement(By.xpath("emtpy table"));
Actions action2 = new Actions(driver);
action2.dragAndDrop(drag1, drop).build().perform();
//drag and drop second element
driver.findElement(By.xpath("open tab 2")).click();
WebElement drag2= driver.findElement(By.id("element in tab 2"));
WebElement drop= driver.findElement(By.xpath("same emtpy table above"));
Actions action = new Actions(driver);
action.clickAndHold(drag2).moveToElement(drop2).release(drop2).perform();
}
@After
public void tearDown() throws Exception {
// driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
the empty table
<div tabindex="10" style="position: relative; overflow: hidden; height:
159px; width: 766px;" class="v-scrollable v-table-body-wrapper v-table-
body"><div style="height: 0px;" class="v-table-body-noselection"><div style="height: 10px;" class="v-table-row-spacer"></div><table class="v-table-table"><tbody></tbody></table><div style="height: 21px;" class="v-table-row-spacer"></div></div><div tabindex="-1" style="position: fixed; top: 0px; left: 0px;"></div></div>