Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用seleniumw webdriver java的jQuery/Javascript_Java_Javascript_Jquery_Testing_Webdriver - Fatal编程技术网

使用seleniumw webdriver java的jQuery/Javascript

使用seleniumw webdriver java的jQuery/Javascript,java,javascript,jquery,testing,webdriver,Java,Javascript,Jquery,Testing,Webdriver,是否有Javascript或jQuery与SeleniumWebdriver Java一起使用的例子?我在使用selenium进行拖放时遇到问题。我希望在Javascript/jQuery中使用以下代码来执行拖放操作。我不能在测试脚本中使用点击来执行拖放,所以我希望使用jQuery或java脚本来执行拖放。我很难将两者结合起来。我只想建议使用javascript或javascript(any)和selenium webdriver代码在同一脚本中进行拖放 public void test(){

是否有Javascript或jQuery与Selenium
Webdriver Java
一起使用的例子?我在使用selenium进行拖放时遇到问题。我希望在Javascript/jQuery中使用以下代码来执行拖放操作。我不能在测试脚本中使用点击来执行拖放,所以我希望使用jQuery或java脚本来执行拖放。我很难将两者结合起来。我只想建议使用javascript或javascript(any)和selenium webdriver代码在同一脚本中进行拖放

public void test(){                                           
    driver.findElement(By.id("addService")).click();
    driver.findElement(By.id("name")).sendKeys(name);
    driver.findElement(By.id("identifier")).sendKeys(id);
    driver.findElement(By.id("flowStatus")).clear();
    driver.findElement(By.id("flowStatus")).sendKeys(flow);
}

public void dragAndDropElement(WebElement dragFrom, WebElement dragTo) throws Exception {


    Actions actions = new Actions(driver);


     actions.clickAndHold(dragFrom).release(dragTo).build().perform();;
}

public void test() throws Exception {


    WebElement dragFrom = driver.findElement(By.xpath("/html/body/div/div[2]/div[1]/form/fieldset/table[1]/tbody/tr/td[1]/div/div[1]"));
    WebElement dragTo = driver.findElement(By.id("drop"));

    dragAndDropElement(dragFrom,dragTo);
}

是否尝试过使用
操作
类?给你。有多种方法可以使用它拖放元素

public void test(){                                           
    driver.findElement(By.id("addService")).click();
    driver.findElement(By.id("name")).sendKeys(name);
    driver.findElement(By.id("identifier")).sendKeys(id);
    driver.findElement(By.id("flowStatus")).clear();
    driver.findElement(By.id("flowStatus")).sendKeys(flow);
}

public void dragAndDropElement(WebElement dragFrom, WebElement dragTo) throws Exception {


    Actions actions = new Actions(driver);


     actions.clickAndHold(dragFrom).release(dragTo).build().perform();;
}

public void test() throws Exception {


    WebElement dragFrom = driver.findElement(By.xpath("/html/body/div/div[2]/div[1]/form/fieldset/table[1]/tbody/tr/td[1]/div/div[1]"));
    WebElement dragTo = driver.findElement(By.id("drop"));

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

public void test(){                                           
    driver.findElement(By.id("addService")).click();
    driver.findElement(By.id("name")).sendKeys(name);
    driver.findElement(By.id("identifier")).sendKeys(id);
    driver.findElement(By.id("flowStatus")).clear();
    driver.findElement(By.id("flowStatus")).sendKeys(flow);
}

public void dragAndDropElement(WebElement dragFrom, WebElement dragTo) throws Exception {


    Actions actions = new Actions(driver);


     actions.clickAndHold(dragFrom).release(dragTo).build().perform();;
}

public void test() throws Exception {


    WebElement dragFrom = driver.findElement(By.xpath("/html/body/div/div[2]/div[1]/form/fieldset/table[1]/tbody/tr/td[1]/div/div[1]"));
    WebElement dragTo = driver.findElement(By.id("drop"));

    dragAndDropElement(dragFrom,dragTo);
}

还有其他的方法,看看哪一种适合你。通常,在使用WebDriver时应避免使用javascript。WebDriver使用浏览器本机api并模拟非常接近真实用户的用户交互。考虑到这一点,您的用户不会执行javascript来进行拖放操作。我建议您仅在所有其他WebDriver车门关闭时使用它。

这是您想要的吗?不,我尝试了所有这些,只是想了解如何将SeleniumWebDriver与JavaScription结合使用。我尝试了这个方法,但没有效果。我正在尝试将一个项目从一个div移动到另一个div。我试过用这个,但没用
public void test(){                                           
    driver.findElement(By.id("addService")).click();
    driver.findElement(By.id("name")).sendKeys(name);
    driver.findElement(By.id("identifier")).sendKeys(id);
    driver.findElement(By.id("flowStatus")).clear();
    driver.findElement(By.id("flowStatus")).sendKeys(flow);
}

public void dragAndDropElement(WebElement dragFrom, WebElement dragTo) throws Exception {


    Actions actions = new Actions(driver);


     actions.clickAndHold(dragFrom).release(dragTo).build().perform();;
}

public void test() throws Exception {


    WebElement dragFrom = driver.findElement(By.xpath("/html/body/div/div[2]/div[1]/form/fieldset/table[1]/tbody/tr/td[1]/div/div[1]"));
    WebElement dragTo = driver.findElement(By.id("drop"));

    dragAndDropElement(dragFrom,dragTo);
}