Home > Blockchain >  Tried all the selenium click option but click is not working on an element
Tried all the selenium click option but click is not working on an element

Time:05-05

WebElement n=driver.findElement(By.cssSelector("tr:nth-of-type(1) > td:nth-of-type(7)"));
JavascriptExecutor j = (JavascriptExecutor) driver;
j.executeScript("arguments[0].click();", n);

HTML Page

<td ><span ><svg  focusable="false" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></svg></span></td>

I tried action class & javaexecuter too but it didnt work.

CodePudding user response:

I think you are trying to click on an SVG image, which are handled differently from the conventional elements.

driver.find_element(By.XPATH, "//*[name()='svg' and @class='MuiSvgIcon-root')]")

This should work, if the svg is what you are trying to click. If you have only one svg element in the DOM, then a simple svg locator like the below should work.

driver.find_element(By.XPATH, "//*[name()='svg']")
  • Related