htmlelements
htmlelements copied to clipboard
Questing regarding ajax pull
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.
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.
Because I can't even use Thread.Sleep. How about AjaxElementLocator.
Isn't AjaxElementLocator
used by default. So, when searching for searchResult
it should wait for 5 seconds before giving up and throwing an error.
Actually, htmlelements works as expected it was how select option was working. I put full xpath and it worked. Thanks for your help.
@akrambek could you post the full xpath here in case others find it useful, then can this issue be closed?