Загрузка...

✔ Drag Slider Horizontally via Selenium Actions | (Video 61)

Drag Slider Horizontally via Selenium Actions Dragging a slider horizontally (left and right) requires a Selenium method called dragAndDropBy. The 3 parameters are source, xOffset, and yOffset. Source is the element’s starting point while x moves the element horizontally. This video demo How To Drag A Slider Left and Right (Horizontally). ► Download Transcript and Code https://www.rexjones2.com/drag-slider-vertically/ ► Documentation via GitHub https://github.com/RexJonesII/Free-Videos/tree/master/Video%2061_Drag%20Slider_Horizontally ► Free Selenium PDF Book: https://www.rexjones2.com/book-selenium-4-beginners/ ► Free Java PDF Book: https://www.rexjones2.com/book-part-1-core-java/ ► All Paperback & eBooks: http://tinyurl.com/Rex-Allen-Jones-Books ► Connect With Me via LinkedIn https://www.linkedin.com/in/rexjones34/ ► Subscribe To This Channel https://www.youtube.com/c/RexJonesII?sub_confirmation=1 ► Transcript In this video, we are going to automate dragging this slider to the left and right using Selenium’s Actions class. Also get the value. The application is range slider. Before we test, let’s load the AUT by writing driver.get("https://rangeslider.js.org/"); Start by writing our WebElements. WebElement slider and WebElement output. Now let’s find the element. Inspect the slider and write //div[@id='js-rangeslider-0']/div[2]. Bingo – Copy the value. Go back to Eclipse. = driver.findElement(By.xpath("//div[@id='js-rangeslider-0']/div[2]")); driver.findElement(By) Inspect the output and the value is js-output. driver.findElement(By.id("js-output")); Next, we the add the Actions class with object reference act = new Actions (driver). act and our method is dragAndDropBy. Let’s look at the syntax. In the previous session, we used dragAndDrop to move the source to the target. In this session, we are going to move the source using the xOffset. The description states “A convenience method that performs click-and-hold at the location of the source element, moves by a given offset, then releases the mouse.” From the parameters section, we see x and y are the offsets. x moves horizontally which is left and right while the y moves vertically up and down. The source is slider and lets moves the slider left by making x negative 100, and y is 0. Finally, we perform the action by selecting perform. Let’s print the output so we can see the value in the console. sysout System.out.println("What Is The Output After Dragging Left? " + output.getText()); Let’s Run. The Console shows 110 after dragging slider left. I’m going to copy and paste the code for moving the slider left. Our method will drag the slider right. So I’m going to change left to right for the method name and print statement then change negative 100 to positive 100. Let’s Run. Now the console shows 110 after dragging slider left and 490 after dragging slider right. Next, we will automate dragging a slider up and down. #DragSlider #SeleniumActions #BeginnerSeleniumTutorials #SeleniumWebDriver

Видео ✔ Drag Slider Horizontally via Selenium Actions | (Video 61) автора JavaScript для начинающих разработчиков
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки