Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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
拖放功能在带有nodejs(javascript)测试自动化框架的selenium webdriver中不起作用_Javascript_Node.js_Selenium_Automation_Action - Fatal编程技术网

拖放功能在带有nodejs(javascript)测试自动化框架的selenium webdriver中不起作用

拖放功能在带有nodejs(javascript)测试自动化框架的selenium webdriver中不起作用,javascript,node.js,selenium,automation,action,Javascript,Node.js,Selenium,Automation,Action,我使用的是seleniumwebdriver+nodejs自动化框架。尝试使用actions类拖放滑块,但不起作用。下面是我的代码片段和错误: 代码: let element: string = "//div[@class='rc-slider']/div[contains(@class,'rc-slider-handle-1')]"; const actions = driver.actions({ bridge: true }); actions.dragAndDrop(element,

我使用的是seleniumwebdriver+nodejs自动化框架。尝试使用actions类拖放滑块,但不起作用。下面是我的代码片段和错误:

代码:

let element: string = "//div[@class='rc-slider']/div[contains(@class,'rc-slider-handle-1')]";

const actions = driver.actions({ bridge: true });

actions.dragAndDrop(element, { x: 100, y: 0 }).build().perform();

TypeError: location.getId is not a function
      at ActionSequence.mouseMove 
      at process._tickCallback (internal/process/next_tick.js`:188:7`)

尝试以下代码,以解决您的问题

public static void draganddrop(WebDriver driver, String src_xpathExpression, String Des_xpathExpression ) {

    WebElement src = driver.findElement(By.xpath(src_xpathExpression));
    WebElement des = driver.findElement(By.xpath(Des_xpathExpression));
    Actions action = new Actions(driver);
    action.clickAndHold(src).moveToElement(des).release().build();

}

我在寻找javascript的变通方法,而不是java