0

The .click() is not doing the click action on the button. Howsoever I change the identifier with css, xpath it does not click it. I am not sure what is wrong and what am I missing. Any help is appreciated.

my html looks like this.

<form autocomplete="off" class="Form form-container" name="">
    <div class="overlay-action-buttons-container-float">
        <button aria-disabled="false" aria-label="Back" class="Button Button--secondary" formnovalidate="" type="button">
            <span class="Button__text">Back</span>
        </button>
        <button aria-disabled="false" aria-label="Submit" class="Button Button--primary" formnovalidate="" type="submit">
            <span class="Button__text">Submit</span>
        </button>
    </div>
</form>

I tried with the below identifiers, but no luck.

@FindBy(css = "div.funds-transfer button[aria-label=\"Submit\"] span")
@FindBy(css = "div.funds-transfer button[aria-label=\"Submit\"]")
@FindBy(css = "button[aria-label=\"Submit\"]")
@FindBy(css = "button[type=\"submit\"]")
@FindBy(xpath = "//span[contains(text(), 'Submit')]")

This is my click method.

public void clickTransferSubmitBtn() {
        scenario.write("i am inside button click method.");
        basePage.waitForClickable(transferModelTransferSubmitBtn);
        transferModelTransferSubmitBtn.click();
        //js.executeScript("arguments[0].click();", transferModelTransferSubmitBtn);
}
Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24
mmar
  • 1,840
  • 6
  • 28
  • 41
  • Share the error trace. Also share URL if possible. – Shawn Jul 31 '23 at 14:48
  • I do not see any error. I see my step is passed. But actually it is not clicking the button and my successive steps are failing because of this. Also i cannot share the url, as it is client app. – mmar Jul 31 '23 at 14:51

1 Answers1

0

Given the HTML:

<form autocomplete="off" class="Form form-container" name="">
    <div class="overlay-action-buttons-container-float">
    <button aria-disabled="false" aria-label="Back" class="Button Button--secondary" formnovalidate="" type="button">
        <span class="Button__text">Back</span>
    </button>
    <button aria-disabled="false" aria-label="Submit" class="Button Button--primary" formnovalidate="" type="submit">
        <span class="Button__text">Submit</span>
    </button>
    </div>
</form>

To click on the <button> with text Submit you can use either of the following locator strategies:

  • Using cssSelector:

    @FindBy(css = "form.Form.form-container button[aria-label=Submit] span.Button__text")
    
  • Using xpath:

    @FindBy(xpath = "//form[@class='Form form-container']//button[@aria-label='Submit']//span[@class='Button__text' and text()='Submit']")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks for your inputs. But nothing was working for me. Finally i found out that actions class helped me. The normal `.click()` and `.submit()` are not worked. So i did like this and worked well `actions.moveToElement(transferModelTransferSubmitBtn).click().build().perform();` – mmar Jul 31 '23 at 15:32