htmlelements icon indicating copy to clipboard operation
htmlelements copied to clipboard

Questing regarding ajax pull

Open akrambek opened this issue 9 years ago • 5 comments

Hi there,

I am trying to create a block for bootsrap select2 element. Here is my code.

@Name("Select2")
public class Select2DropDownList extends HtmlElement {

    @FindBy(className = "select2-choice")
    Link selectLink;

    @FindBy(xpath = "//*[@id='select2-drop']/div/input")
    TextInput searchTextInput;

    @FindBy(xpath = "//*[@id='select2-drop']/ul")
    Ul selectResult;

    public void selectOptionThatContains(String value) {
        selectLink.click();
        searchTextInput.clear();
        searchTextInput.sendKeys(value);
        selectResult.selectOptionThatContains(value);
    }
}

The problem I am facing is that once searchTextInput.sendKeys(value) is being called it is taking sometime for result to appear. So how can I add wait after searchTextInput.sendKeys(value). Any example? Thank you in advance.

akrambek avatar Apr 16 '15 16:04 akrambek

I'm not sure if there is native wait function that would periodically (several times in a second) check if element if present and when it will be present will call some action on it.

aik099 avatar Apr 16 '15 16:04 aik099

Because I can't even use Thread.Sleep. How about AjaxElementLocator.

akrambek avatar Apr 16 '15 17:04 akrambek

Isn't AjaxElementLocator used by default. So, when searching for searchResult it should wait for 5 seconds before giving up and throwing an error.

aik099 avatar Apr 17 '15 07:04 aik099

Actually, htmlelements works as expected it was how select option was working. I put full xpath and it worked. Thanks for your help.

akrambek avatar Apr 18 '15 04:04 akrambek

@akrambek could you post the full xpath here in case others find it useful, then can this issue be closed?

ham1 avatar Jun 10 '16 15:06 ham1