✔ Drag & Drop Target via Selenium Actions Class | (Video 60)

Опубликовано: 04 Сентябрь 2019
на канале: Rex Jones II
506
10

Selenium has the capability to perform many advanced keyboard and mouse events. One of those capabilities is dragging and dropping an element. The parameters for dragAndDrop is source and target. Source is the element’s starting point while target is the element’s dropping point. This video demo How To Drag And Drop A Target using Selenium Actions Class.

► Download Transcript and Code https://www.rexjones2.com/drag-drop-t...
► Documentation via GitHub https://github.com/RexJonesII/Free-Vi...

► Free Selenium PDF Book: https://www.rexjones2.com/book-seleni...
► Free Java PDF Book: https://www.rexjones2.com/book-part-1...
► All Paperback & eBooks: http://tinyurl.com/Rex-Allen-Jones-Books

► Connect With Me via LinkedIn   / rexjones34  
► Subscribe To This Channel https://www.youtube.com/c/RexJonesII?...

► Transcript
In this video, we are going to drag this element to this Drop Here element using Selenium’s Actions Class. Inspect both WebElements. Right click the first WebElement and we see draggable as the value for id. Right click the second element and the value for id is droppable.
Let’s go to Eclipse, we have our set up and tear down methods. The test method is dragAndDropTarget. Start by loading the application: driver.get("https://jqueryui.com/droppable/");

There are 2 WebElements. First is WebElement source = driver.findElement(By.id("draggable")). The value for id is draggable. Next is the target. WebElement target = driver.findElement(By.id("droppable")); The value for id is droppable. Import WebElement. Did you notice that both WebElements were located inside an iFrame?

Close the DOM and right click again. View Frame Source is an indicator that the WebElements are within a frame. Recall from the Switch To Frame Videos 29 – 32, we must switch to the frame before performing a command on the WebElement. If not, we will get an Exception while executing our Test Script.

Let’s write //iframe and we see there is only 1 iframe on this webpage. As a result, we can use the index to locate the only iFrame. Go back to Eclipse and add our switch statement. driver.switchTo().frame(0);

Now, we implement the Actions class with act as the object reference = new Actions driver in the parenthesis. Import the Actions class. Object Reference act dot dragAndDrop. Here we go, the drag and drop methods. Look at the description “A convenience method that performs click-and-hold at the location of the source element, moves to the location of the target element, then releases the mouse.” The parameters are source and target. Next, we perform the action by writing perform. Let’s Run. That’s It for Dragging Then Dropping A Target

#Drag-Drop Target #Selenium Actions #BeginnerSeleniumTutorials #SeleniumWebDriver


Смотрите видео ✔ Drag & Drop Target via Selenium Actions Class | (Video 60) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Rex Jones II 04 Сентябрь 2019, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 506 раз и оно понравилось 10 людям.