2016-08-09 3 views
0
package Chrome_Packg; 

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; 

public class testFirefox_DragDrop { 

    public static void main(String[] args) throws InterruptedException { 
     WebDriver driver=new FirefoxDriver(); 
     driver.get("http://jqueryui.com/droppable/"); 

     WebElement drag=driver.findElement(By.xpath("/html/body/div[1]"));//drag element 
     WebElement drop=driver.findElement(By.xpath("/html/body/div[2]"));//drop element 

     Actions action=new Actions(driver); 
     Thread.sleep(3000); 
     action.dragAndDrop(drag, drop).perform(); 


    } 

} 

Javaアプリケーションとして実行を使用してコードを実行した後、出力で何も表示されません。ここでアクションを使用してドラッグ&ドロップを実行することができません

答えて

0

は、あなたがしようとしている同じWebサイトのコードスニペットであり、あなたもここでselenium Drag and Drop example

driver = new FirefoxDriver(); 
    driver.manage().window().maximize(); 
    driver.navigate().to("http://jqueryui.com/droppable/"); 
    //Wait for the frame to be available and switch to it 
    WebDriverWait wait = new WebDriverWait(driver, 5); 
    wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector(".demo-frame"))); 
    WebElement Sourcelocator = driver.findElement(By.cssSelector(".ui-draggable")); 
    WebElement Destinationlocator = driver.findElement(By.cssSelector(".ui-droppable")); 
    dragAndDrop(Sourcelocator,Destinationlocator); 
    String actualText=driver.findElement(By.cssSelector("#droppable>p")).getText(); 
    Assert.assertEquals(actualText, "Dropped!"); 
例を見つけることができます
関連する問題