We convey already learnt how to drag together with drib drag-able spider web chemical portion on drop-able spider web chemical portion In THIS POST together with drag together with drib chemical portion for specific X Y pixel firstly In THIS POST using selenium webdriver's Advanced User Interactions API (Actions class). Now supposing yous wants to pick out multiple jQuery select-able Items together with hence besides yous tin use WebDriver's activity command. Till now, I convey non become peril to purpose this matter practically In whatever of my projection but yet allow me part It amongst yous because yous tin produce It using WebDriver's Action class together with mightiness It helps yous In whatever application's evidence instance creation.
Selecting multiple Items agency performing sequence of actions. In this case, We convey to use clickAndHold method of Actions class to pick out multiple Items from jQuery select-able Items. I convey prepared sum practical illustration to perform this chore equally bellow.
package Testing_Pack; import java.util.List; 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.Action; import org.openqa.selenium.interactions.Actions; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; world degree DragAndDrop { 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 { //Prepare listing of selectable Items List<WebElement> selectableItems = driver.findElements(By.xpath("//ol[@id='selectable']/*")); //Build the pick out Item action. Actions toSelect = novel Actions(driver); toSelect.clickAndHold(selectableItems.get(2)).clickAndHold(selectableItems.get(5)).click(); //Perform action. Action selectItems = toSelect.build(); selectItems.perform(); } }
So this Is about other illustration of WebDriver's advanced user Interaction. Here my indicate Is non how to select jQuery Selectable Items but my indicate Is how together with when to purpose Actions degree together with Its method clickAndHold.