Select Text Using DoubleClick from WebDriver Java

java, selenium, selenium-webdriver

Solution

if you want to select all the text you can do it like this...

driver.findElement(By.xpath("xpath")).sendKeys(Keys.chord(Keys.CONTROL, "a"));

Problem

I want to do double click on search inputbox of google page and it should be selected This is my code : ``` WebDriver driver = new FirefoxDriver(); driver.navigate().to("http://www.google.com"); WebElement oWE = driver.findElement(By.name("q")); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.presenceOfElementLocated(By.name("q"))); if (oWE.isDisplayed()) { System.out.println("Displayed"); oWE.sendKeys("abcd"); driver.findElement(By.id("gbqfb")).click(); Actions oAction = new Actions(driver); oAction.moveToElement(oWE); oAction.doubleClick(oWE).build().perform(); } ``` but text is not selected. 1.Why it is not working? 2.We always use By.ID,By.name etc why we do not use ById.Id ByName.name etc if we can use this where it should be used if not why we did not use this?

Original source