0

I try to double click on the text box by which the text will be selected.....The code looks like

    WebDriver driver=new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get("https://www.facebook.com/");
    WebElement txtBoxElement=driver.findElement(By.xpath("//*[@id='email']"));
    txtBoxElement.sendKeys("abc");
    System.out.println("Test start");
    Actions builder=new Actions(driver);
    Action a=builder.moveToElement(txtBoxElement).doubleClick(txtBoxElement).build();
    a.perform();

    //This is for another way to double click on the text field 

    Locatable locatable = (Locatable) driver.findElement(By.name("email"));
    Mouse mouse = ((HasInputDevices) driver).getMouse();
    mouse.mouseMove(locatable.getCoordinates());
    mouse.doubleClick(locatable.getCoordinates());


    System.out.println("Test Complete");
}

but both of this way was not working I bypass this problem using this

    Action a=builder.moveToElement(txtBoxElement).sendKeys(txtBoxElement,Keys.chord(Keys.CONTROL,"a")).build();
    a.perform();

my question is why double click is not working? I also try this for google search textbox it was also not working. Here I want to mention one thing that I use Selenium 2.37 and firefox 26 .

I did not get any error but not double click on this element.I also observe that if I commented out the txtBoxElement.sendKeys("abc"); part and then sendkeys using Actions event,it write the text on browser address bar.

saba
  • 539
  • 1
  • 14
  • 30

3 Answers3

1

I believe you must be seeing following error while double clicking an element:

Cannot perform native interaction: Could not load native events component.

This is always issue with latest version of Firefox with latest verion of Selenium WebDriver(For more details please refer to link).

You can resolve this issue by downgrading Firefox from 26 to 25. With Firefox 25 your code will work.

Community
  • 1
  • 1
Alpha
  • 13,320
  • 27
  • 96
  • 163
  • I did not get any error but not double click on this element.I also observe that if I commented out the txtBoxElement.sendKeys("abc"); part and then sendkeys using Actions event then it write the text on browser address bar. – saba Dec 26 '13 at 10:09
0

It may be that you have the Action statement incorrect for the double-click. I did a double-click with simple statements like this:

Actions a = new Actions(driver);<br>
a.doubleClick(txtBoxElement);<br>
a.perform();
Eric Alberson
  • 1,116
  • 1
  • 11
  • 23
0

If you are trying to select all of the text in the text box try:

WaitUntil.elementReady(driver, 2,".//span[@class='scale-input-box']/input").sendKeys(Keys.CONTROL + "a");

To overcome problems with doubleclicking in Selenium try Alternative workaround Source

Simplified to this:

((JavascriptExecutor) driver).executeScript("document.getElementById('map_container').dispatchEvent(new Event('dblclick'));"); 
Miriam Farber
  • 18,986
  • 14
  • 61
  • 76
dank8
  • 361
  • 4
  • 20