O'Reilly logo

Mastering Selenium WebDriver 3.0 by Mark Collin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with drag and drop

Another HTML construct that is hard to work with is a page that allows you to drag and drop elements. For this example, we will create a simple HTML page that uses jQuery to allow us to drag some elements around the screen. We are also going to add an element that will destroy any of the draggable elements that we drop onto it so that these draggable elements can be removed from the page. Let's start off with the basic HTML:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset=utf-8> 
    <title>Drag and drop</title> 
    <style type="text/css">${TBC}</style> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery    /2.1.3/jquery.min.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui /1.11.3/jquery-ui.min.js"></script> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required