2017-07-11 9 views
1

コードが正常に動作することになっているの下に..問題が何であるかわからない。..ドラッグNドロップが起きていない

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; 

public class jusTrails { 

    public static void main(String[] args) { 
     System.setProperty("webdriver.gecko.driver", "D:\\bala back up\\personel\\selenium\\Jars\\Drivers\\geckodriver.exe"); 
     WebDriver driver=new FirefoxDriver(); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
     driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS); 

     driver.get("http://www.seleniumeasy.com/test/drag-and-drop-demo.html"); 
     WebElement onlyOne=driver.findElement(By.xpath("//span[contains(text(), 'Draggable 1')]")); 

     System.out.println(onlyOne.getText()); 
     WebElement dropHere1=driver.findElement(By.xpath("//*[@id='mydropzone']")); 
     Actions act=new Actions(driver); 
     act.dragAndDrop(onlyOne, dropHere1).build().perform(); //This should work fine.. BUT. 

    } 

} 

私は文句を言わないで、すべての移動は例外なく、ドラッグ可能な1を取得していないのですが..私はこれを試してみました別の方法が、運...

Actions builder = new Actions(driver); 

Action dragAndDrop = builder.clickAndHold(onlyOne) 
    .moveToElement(dropHere1) 
    .release(dropHere1) 
    .build(); 

dragAndDrop.perform(); 
+0

チェック –

+0

なしのXPathの問題..私は実際にその – bbk

+0

は私が行うことができる午前http://jqueryui.com/resources/demos/droppable/default.htmlで同様の手順を試しについて確信しています..上のものに何が間違っているのかわからない – bbk

答えて

1

にこれは明らかに知らissueあるとworkaroundがあります。それはRubyにあると認められています。あなたのXPathと

def drag_and_drop(source,target) 

    js_filepath=File.dirname(__FILE__)+"/drag_and_drop_helper.js" 
    js_file= File.new(js_filepath,"r") 
    java_script="" 

    while (line=js_file.gets) 
     java_script+=line 
    end 

    js_file.close 

    @driver.execute_script(java_script+"$('#{source}').simulateDragDrop({ 
dropTarget: '#{target}'});") 

    rescue Exception => e 
     puts "ERROR :" + e.to_s 

    end 
+0

非常に不幸なことに、そこには回避策がありません。 @TitusLucretiusの入力をありがとう – bbk

関連する問題