RE: Problem in handling auto suggestion

Hi All,

I was writing a webdriver code to handle auto suggestion ( for the homa page “keywork” field. but it is unable to locate the suggested element..please help me…

package Simple;

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.Test;

public class AutoSuggestion {
public void select() throws InterruptedException
WebDriver d = new FirefoxDriver();
Actions a = new Actions(d);

WebElement w = d.findElement(By.cssSelector(“‪#‎ui‬-id-4″));//this line is unable to locate element.



snpanigrahi9 Train Asked on November 15, 2014 in Selenium WebDriver.


After running your code I am getting below error message.

Note: Please let us know what you are trying to do here OR give a steps.

Unable to locate element: {"method":"css selector","selector":"?#?fts_id?"}

Command duration or timeout: 150 milliseconds

For documentation on this error, please visit:

Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'

on November 16, 2014.

@Sachin: correct, code is not working.

Action should not use here, key, mouse actions are different and webdriver actions. :).

Up voted for your solution.

on November 16, 2014.
Add Comment
3 Answers

One Way:
You should include explicit wait statement


Another Way:
Use Webdriver wait it will wait until the predicate isTrue or until the time Out expires.

webDriverWait = (new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(final By locator)));

In Real time avoid thread.sleep because its not good way. In case of webdriver wait there is polling happen so its good way.

Train Answered on November 17, 2014.

Yes, correct.

on November 18, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.