Sabbir Sohan Sabbir Sohan - 7 days ago 4x
Java Question

How to locate and type something in the textbox

public class testFluent {

WebDriver driver;
public void setUp(){
driver = new FirefoxDriver();

public void myFirstFluent(){
WebElement element;
element = myDynamicElement("//*[@id='p_13838465-p']"));
System.out.println("Element found");

public WebElement myDynamicElement(final By locator){

Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(10, TimeUnit.SECONDS)
.pollingEvery(100, TimeUnit.MILLISECONDS)

WebElement element = wait.until(new Function<WebElement, WebDriver>(){

public WebElement apply(WebDriver drv){
return drv.findElement(;

return element;


I am unable to locate and ends with Error.

java.lang.Error: Unresolved compilation problems: The method until(Function) in the type Wait is not applicable for the arguments (new Function(){}) Function cannot be resolved to a type

The method id(String) in the type By is not applicable for the arguments (By) at


For wait you can use something like this

    private boolean wAit(String match)
        (new WebDriverWait(driver, 30))
            .until(ExpectedConditions.presenceOfElementLocated (By.xpath(match)));
        return true;
    catch (NoSuchElementException e) {
        return false;

You can create the above method and use it where ever you need to wait for an element. for example

if want a write something in the textbox and want to wait for the text box to load

wAit(" xpath of the textbox here")
driver.findelements... sendkeys()..

If you want you can change the locator type and increase/decrease the time limit also