I am trying to click on a button on an application which is react based. It throws NoSuchElementException. I am very sure that the element name is correct . I tried with CSS, XPATH but nothing worked. Initially I thought I might be somehow using the wrong element . So to rule out this possibility I used selenium IDE and Katalon studio and did a click on that element to capture the correct XPATH or CSS. But, interestingly selenium or Katalon both did not capture the element. Instead they both showed that I click on this “agentx-app” option which is not a button or any clickable item.
Button element:
<button part="button" id="" class="md-button md-button--32" tabindex="0" aria-pressed="false" aria-label="Unavailable" aria-labelledby="" aria-expanded="false" aria-haspopup="false" type="button" role="button">
<span class="md-button__children">
<slot name="text"></slot>
<slot></slot>
</span>
</button>
Please see the image . Added image as I could not copy the HTML content.
None of the below worked:
public static void clickElement(String type, String tag) {
if (type.equals("name")) {
driver.findElement(By.name(tag)).click();
} else if (type.equals("tagName")) {
driver.findElement(By.tagName(tag)).click();
} else if (type.equals("id")) {
driver.findElement(By.id(tag)).click();
} else if (type.equals("xpath")) {
driver.findElement(By.xpath(tag)).click();
} else if (type.equals("css")) {
driver.findElement(By.cssSelector(tag)).click();
} else if (type.equals("linkText")) {
driver.findElement(By.linkText(tag)).click();
} else if (type.equals("classname")) {
driver.findElement(By.className(tag)).click();
}
}
Calling click button:
public void clickButton() {
UtilWebDriver.waitForPageToLoad("xpath", "//*[@id="menu-overlay"]/md-tooltip/md-button//button");
UtilWebDriver.clickElement("xpath", "//*[@id="menu-overlay"]/md-tooltip/md-button//button");
}
I simply am not able to interact with the buttons. And there does not appear to be any iframe as well . Any idea.