Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In some cases there is no action on the web elements, which available only after load form completely

I use htmlelements pattern, similar on pagefactory. Search for elements going through the @FindBy. With some elements can not perform the action (click, sendkeys...), because form on the page is not fully to load and does not appear to perform an action on it, and the driver is already trying to do actions for it. Helps only method Thread.sleep(). But I would like to use Explicit Waits. Timeouts(), a member of the htmlelements not help. For example:

public class ButtonForm extends HtmlElement {

    @FindBy(xpath = "//span[text()='Select']")
    public Button selectButton;

    public void selectButton() {
        selectButton.click();
    }

In the current test the behavior of a long running and there is no click operation. I would like to implement something like this ligament: "WebElement + WebDriverWait + ExpectedConditions"

like image 880
BCR Avatar asked Dec 29 '25 02:12

BCR


1 Answers

The problem probably is here @FindBy(xpath = "//span[text()='Select']"). When you start xpath expression with a // selenium ignores element context and looking up from document root. So maybe your action (click, sendkeys) works, but on wrong elements. To fix this issue, start your xpath with a ./ or use css locators.

like image 61
artkoshelev Avatar answered Dec 30 '25 16:12

artkoshelev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!