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
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
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")));
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);
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"]
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.