【问题标题】:Drag and Drop function is not working in selenium webdriver with nodejs (javascript) test automation framework拖放功能在带有nodejs(javascript)测试自动化框架的selenium webdriver中不起作用
【发布时间】:2020-02-06 05:21:22
【问题描述】:

我正在使用 selenium webdriver + nodejs 自动化框架。尝试使用操作类拖放滑块但不工作。下面是我的代码 sn-p 和错误:

代码:

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`)

【问题讨论】:

    标签: javascript node.js selenium automation action


    【解决方案1】:

    试试下面的代码它可以解决你的问题

    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 中
    猜你喜欢
    • 2023-03-31
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多