0

enter image description here

I am trying to locate an element to click in order to Sign In , not able to succeed.

I tried the below steps,

Click Element    class=mat-raised-button mat-accent
Click Element    class=mat-focus-overplay
Click Button     link=Sign In
  • 1
    The button is "disabled" according to the HTML, see last line first row. – Niels van Reijmersdal Nov 11 at 13:53
  • Many times you need to wait until an element is enabled/visible etc. With Selenium, you need to take this into account since Selenium won't wait automatically. – puzzle Nov 11 at 13:58
1

It seems you are trying to click on the disabled icon. Selenium does not click on the disabled button.

You can wait until the element gets enabled using WebDriverWait.

WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".mat-raised-button.mat-accent")));
0

Your first attempt would work if the button was not disabled.

Your other attempts are failing because <span> elements aren't clickable.

My suggestion is to first locate the <button> element, then use Javascript Executor to enable it. At this point you will be able to click it.

In a c#-ish pseudo-code, this would look something like this:

IWebElement button = driver.FindElement(By.Class("mat-raised-button mat-accent"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].removeAttribute("disabled"), button);

0

It looks like you are trying to click a disabled element. If the button was not disabled as it is seen in the first tag;

WebElement button = webDriver.findElements(new ByChained(
                        By.cssSelector("button[type='submit']"),
                        By.className("button[class='mat-raised-button mat-accent']"))[0]; 
//You can replace [0] by 
button.click();

Edit: Okay, since you said when you fill the username and pw the field get enabled. There's two thing that you should pay attention, the locator that you use and waiting until element get enabled. For the HTML above my locator suggestion would be as above updated. You might consider to ask developers for adding data-qa-id for element to make it easier.

0

First, wait until the button is enabled, then click the button tag:

    Wait Until Element Is Enabled    css:*[class="mat-raised-button mat-accent"]    10
    Click Element    css:*[class="mat-raised-button mat-accent"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.