From the course: Python Automation and Testing

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Drag and drop elements

Drag and drop elements

From the course: Python Automation and Testing

Start my 1-month free trial

Drag and drop elements

- [Instructor] The sites performing actions such as entering text and filling forms, users also drag and drop elements as part of the UI interaction. The Selenium WebDriver provides classes that enables us to automate the drag and drop actions as well. In the Selenium WebDriver you can drag and drop a source element to a target element and also drag and drop a source element by a specific x-offset and a specific y-offset. Let's take a look at a code example to see how this can be done. Let's open IDE and directly being coding. So I'm going to open a new file and as with any other Selenium code, I'm going to import the webdriver first. Also, I'm going to import the time module in order to modulate the timing of our script. Besides this, I'm also going to import ActionChains which is a class that we'll be using during this program. I'll be explaining the function of ActionChains in a while. So let's begin by creating a driver instance. And we'll open the URL, http…

Contents