As y'all know, We tin role WebDriver Actions class where nosotros postulate to perform series of actions to consummate operation. We attain got learnt many tutorials on usage of Actions shape In selenium webdriver to perform such tricky advanced user Interactions similar drag as well as driblet element, selecting JQuery selectable Items, Moving slider, selecting appointment from JQuery appointment picker etc.. You tin persuasion all these advanced user Interactions tutorials links on THIS PAGE alongside practical examples on each one.
Same way, Double clicking on button Is serial of actions every bit y'all needs to click 2 fourth dimension on button. Simple unmarried push click Is possible past times click() method In webdriver but to perform double click action, nosotros postulate to role Actions shape of selenium webdriver. You tin acquire how to correct click on guide pick from context carte du jour In THIS POST.
I attain got created practical event to demo y'all how to role Actions shape alongside doubleClick() as well as perform() methods to double click on element.
package Testing_Pack; import java.io.IOException; 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 shape DoubleClick { WebDriver driver; @BeforeTest world void setup() throws Exception { driver =new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get(" "); } @Test world void doubleClick_Button() throws IOException, InterruptedException { WebElement ele = driver.findElement(By.xpath("//button[contains(.,'Double-Click Me To See Alert')]")); //To generate double click activeness on "Double-Click Me To See Alert" button. Actions activeness = novel Actions(driver); action.doubleClick(ele); action.perform(); Thread.sleep(3000); String alert_message = driver.switchTo().alert().getText(); driver.switchTo().alert().accept(); System.out.println(alert_message); } }
When y'all function example, It volition double click on "Double-Click Me To See Alert". Rest of code Is to handgrip alarm generated past times push double click. So this Is the means to double click on whatever chemical component subdivision In selenium webdriver test.
http://www.software-testing-tutorials-automation.com/