samedi 28 octobre 2017

Unable to Drag & Drop in Selenium WebDriver 3.6

I am trying to drag & drop but its not working.

Here is my code.

Please help, I have applied so much time on this, but it is still not working.

Chrome Version: 62.0.3202.75 ChromeDriver : 2.33 Selenium : 3.6

public class Drag_And_Drop {
static String baseURl="https://www.google.com";
static WebDriver driver;

@BeforeMethod
public void openBrowser() {     
    System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/drivers/chromedriver.exe");
    driver=new ChromeDriver();
    driver.get(baseURl);
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(2000, TimeUnit.SECONDS);
}

@Test
public void verifyCount() {

    WebElement searchBox = driver.findElement(By.xpath(".//*[@id='lst-ib']"));
    searchBox.sendKeys("jqwidget drag and drop");
    searchBox.sendKeys(Keys.ENTER);     

    WebElement link = driver.findElement(By.linkText("jQuery DragDrop, DragDrop plug-in, Drag and Drop ... - jQWidgets"));
    link.click();       

    driver.switchTo().frame(0);

    WebElement source = driver.findElement(By.xpath(".//*[@id='jqxWidgete3128591f541']"));
    source.click();

    WebElement target = driver.findElement(By.xpath(".//*[@id='cart']"));       

    Actions actions = new Actions(driver);
    actions.dragAndDrop(source, target).build().perform();
}   

@AfterMethod
public void closeBrowser() {
        driver.quit();
}

}

Aucun commentaire:

Enregistrer un commentaire