2017-05-02 34 views
0

以下のコードでSelenium 3.0のドラッグアンドドロップをテストし、コードが動作していないことを確認します。ドラッグ&ドロップがSelenium 3.0で機能していない

セレン2.53で同じコードを試してみましたが、動作しています。親切にも誰かが私のコードを見直して、私が何かを見逃していたら教えてください。

セレン3.0

ブラウザ:Mozillaの2.52

package dynamicXpath; 

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.firefox.FirefoxProfile; 
import org.openqa.selenium.interactions.Action; 
import org.openqa.selenium.interactions.Actions; 

public class refermeprobI { 

    public static void main(String[] args) throws InterruptedException{ 

    System.setProperty("webdriver.gecko.driver", "D:\\Drivers\\geckodriver.exe"); 

    FirefoxProfile profile = new FirefoxProfile(); 
     profile.setEnableNativeEvents(true);  
     WebDriver driver = new FirefoxDriver(profile); 


      driver.manage().window().maximize(); 
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); 


    driver.get("https://the-internet.herokuapp.com/drag_and_drop"); 

    Actions act = new Actions(driver); 

    WebElement src = driver.findElement(By.xpath("//*[@id='column-a']")); 
    WebElement dst = driver.findElement(By.xpath("//*[@id='column-b']")); 






    act.dragAndDrop(src, dst).build().perform(); 

    System.out.println(driver.findElement(By.xpath("//*[@id='column-b']/header")).getText()); 



} 

} 
+0

あなたのコードにエラーはありません。しかし、私はあなたのMozilla Firefoxのバージョンとgeckodriverのバージョンについてまだよく分かりません。ドラッグ&ドロップはSelenium 3.xでうまくいきました。 – DebanjanB

+0

geckodriverのどのバージョンをお使いですか? –

+0

'setEnableNativeEvents(true)'が償却されているのがわかります。それでも使える? – DebanjanB

答えて

0

また、次の試みることができます。

act.clickAndHold(src).moveToElement(dst).release(src).build().perform(); 

これはdragAndDrop()にはない特定のシナリオで動作します。

0

あなたのコードを確認しました。 Selenium 3.0.0を使用していて希望の機能を設定する必要がある場合を除いて、すべてが問題ありません。私はまた、あなたのコードを最新のSelenium 3.4でチェックしました。 Selenium 3.4を使用する場合は、Desired Capabilitiesを設定する必要はありません。私はFirefox 52を使用しました。 この情報があなたが遭遇した問題を理解するのに役立つことを願っています。 ありがとう

関連する問題