How To Move JQuery Slider In Selenium WebDriver

To drag in addition to drib whatever chemical cistron on other element, We tin purpose moveToElement or dragAndDrop methods of Actions aeroplane equally described In THIS POST. Same way, To movement chemical cistron past times specific X,Y Pixel offset, We tin use dragAndDropBy method of Actions aeroplane equally described on THIS PAGE. To conduct multiple JQuery Items, We tin purpose clickAndHold method of Actions class. Example Is given on THIS PAGE. So Actions aeroplane has many dissimilar such methods to perform this variety of tricky operations on your spider web application using selenium WebDriver.

If you lot convey observed, Now a days, many spider web applications are using sliders to set/change cost attain limits to filter records. You tin expose this variety cost attain sliders on E-Commerce websites. Actions aeroplane tin assistance us to movement this variety of sliders In selenium webdriver attempt case. We tin create same affair In ii dissimilar ways or I tin state using dissimilar methods of Actions aeroplane equally shown In bellow example.

package Testing_Pack;  import java.util.concurrent.TimeUnit;  import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test;  world aeroplane moveSlider {    WebDriver driver = null;    @BeforeTest     world void setup() throws Exception {     driver = novel FirefoxDriver();          driver.manage().window().maximize();          driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);          driver.get(" ");     }     @Test  world void selectItems() throws InterruptedException {     //Locate slider pointer.   WebElement dragElementFrom = driver.findElement(By.xpath("//span[contains(@class, 'ui-slider-handle')]"));              //To Move jQuery slider past times 100 pixel outset using dragAndDropBy method of Actions class.   novel Actions(driver).dragAndDropBy(dragElementFrom, 100, 0).build().perform();   Thread.sleep(5000);      //After v seconds, This volition Move jQuery slider past times 100 pixel outset using the combination of clickAndHold, moveByOffset in addition to unloose methods of Actions class.   novel Actions(driver).clickAndHold(dragElementFrom).moveByOffset(100,0).release().perform();  } }

If you lot run across In inwards a higher house example, I convey used  dragAndDropBy method to movement chemical cistron past times 100 pixel outset In horizontal direction. Same thig nosotros tin create using clickAndHold and moveByOffset methods equally shown In inwards a higher house example.

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post