Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 14, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 14, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 14, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 14, 2025

      I test a lot of AI coding tools, and this stunning new OpenAI release just saved me days of work

      May 14, 2025

      How to use your Android phone as a webcam when your laptop’s default won’t cut it

      May 14, 2025

      The 5 most customizable Linux desktop environments – when you want it your way

      May 14, 2025

      Gen AI use at work saps our motivation even as it boosts productivity, new research shows

      May 14, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Strategic Cloud Partner: Key to Business Success, Not Just Tech

      May 14, 2025
      Recent

      Strategic Cloud Partner: Key to Business Success, Not Just Tech

      May 14, 2025

      Perficient’s “What If? So What?” Podcast Wins Gold at the 2025 Hermes Creative Awards

      May 14, 2025

      PIM for Azure Resources

      May 14, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Windows 11 24H2’s Settings now bundles FAQs section to tell you more about your system

      May 14, 2025
      Recent

      Windows 11 24H2’s Settings now bundles FAQs section to tell you more about your system

      May 14, 2025

      You can now share an app/browser window with Copilot Vision to help you with different tasks

      May 14, 2025

      Microsoft will gradually retire SharePoint Alerts over the next two years

      May 14, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to drag an element and drop it in another frame?

    How to drag an element and drop it in another frame?

    June 26, 2024

    Hope you doing well,

    I’m trying to dragAndDrop an element from FrameOne to FrameTwo but not able to do so.Please help me to understand the concept and what I’m doing wrong here and need to achieve the task by using Actions class only.

    Here’re the URLs :

    https://www.w3schools.com/html/html5_draganddrop.asp
    Here the element is in a div block I’m able to get all the locaters and do all other actions using Actions class but not able to drag and drop the element.

    2.https://codepen.io/rjsmer/full/vvewWp

    Here I’m trying to move the element from Frame one to Frame two but I’m not able to do so.

    I’ve tried dragAndDrop(),ClickAndHold() methods,Searched so many solutions, watch videos on the same with no success.

    package DragAndDropPracticeFrame;

    import io.github.bonigarcia.wdm.WebDriverManager;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.interactions.Action;
    import org.openqa.selenium.interactions.Actions;

    import static io.github.bonigarcia.wdm.DriverManagerType.CHROME;

    public class DragDropFrame {
    public static void main(String[] args) throws InterruptedException {
    WebDriverManager.getInstance(CHROME).setup();
    WebDriver driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.get(“https://codepen.io/rjsmer/full/vvewWp”);
    driver.switchTo().frame(“result”);
    System.out.println(“Inside First Frame.”);
    WebElement frameOne =
    driver.findElement(By.cssSelector(“iframe.dragFrame.dragDrop”));
    driver.switchTo().frame(frameOne);
    System.out.println(“Inside Frame 3”);
    WebElement elementOne = driver.findElement(By.id(“dragFrame-0”));
    System.out.println(“First element found: ” + elementOne.getText());
    Actions builder = new Actions(driver);
    driver.switchTo().defaultContent();
    System.out.println(“Inside main page”);
    driver.switchTo().frame(“result”);
    //System.out.println(“Switched to Frame First”);
    WebElement frameThree =
    driver.findElement(By.xpath(“//iframe[@class=’dropFrame dragDrop’]”));
    Action action =
    builder.clickAndHold(elementOne)
    .moveToElement(frameThree)
    .release(frameThree).build();

    //driver.switchTo().frame(frameTwo);
    //System.out.println(“Switched to frame 3”);
    action.perform();

    //driver.switchTo().defaultContent();
    //builder.perform();

    }
    }

    Another try :

    WebDriverManager.getInstance(CHROME).setup();
    WebDriver driver = new ChromeDriver();
    driver.get(“https://codepen.io/rjsmer/full/vvewWp”);
    driver.switchTo().frame(0);
    WebElement frameOne = driver.findElement(By.xpath(“//iframe[@class=’dragFrame dragDrop’]”));
    WebElement frameTwo = driver.findElement(By.xpath(“//iframe[@class=’dropFrame dragDrop’]”));
    driver.switchTo().frame(frameOne);
    // identify element in first frame
    WebElement elementOne = driver.findElement(By.id(“dragFrame-0”));

    // Use Actions class for tap and hold
    Actions actions = new Actions(driver);
    Actions action = actions.clickAndHold(elementOne);
    actions.build();
    action.perform();

    // switch to the second frame
    driver.switchTo().frame(frameTwo);

    // move element to another frame
    WebElement elementTwo = driver.findElement(By.xpath(“//body[@class=’frameBody dropFrameBody’]”));
    Actions actions2 = new Actions(driver);
    Actions action2 = actions2.moveToElement(elementTwo);
    actions2.release(elementOne);
    actions2.build();
    action2.perform();

    Expected: The element should move to Frame 3 Actual: Nothing happened.

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleQAC messages: What is 5703?
    Next Article Replete-AI Introduces Replete-Coder-Qwen2-1.5b: A Versatile AI Model for Advanced Coding and General-Purpose Use with Unmatched Efficiency

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 15, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-30419 – NI Circuit Design Suite SymbolEditor Out-of-Bounds Read Vulnerability

    May 15, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Charity: Water First of Five Organizations to Receive $5,000 Perficient Gives Global Grant

    Development

    Ignore everything else, this is the true “objective” list of the best Xbox and PC games of 2024

    Development

    DCCOM and SAFC4DC: A Strategic Move to Secure Singapore’s Digital Backbone

    Development

    UX in Universal Design Series: Compatibility in Health Systems for Accessibility and Usability – 8

    Development

    Highlights

    News & Updates

    NVIDIA’s GeForce NOW memberships are “sold out” right now, and it says it’s our fault for using the servers too much

    January 22, 2025

    Most tiers of the popular GeForce NOW game streaming service are “sold out,” and NVIDIA…

    CVE-2025-0049 – GoAnywhere Directory Traversal Information Disclosure

    April 28, 2025

    Cybersecurity Blind Spots in IaC and PaC Tools Expose Cloud Platforms to New Attacks

    November 25, 2024

    Elden Ring and Shadow of the Erdtree system requirements: Can my PC run this game?

    June 17, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.