Andrii Dudchenko
Andrii Dudchenko

Reputation: 91

Selenium click not work

Help me please. Selenium does not click on element and element is clickable(selenium does not generate exception). I try use Id, css, xpath locators, nothing did not help me.

What should i do to decide my problem?

Java code example.

WebElement sector = webDriver.findElement(By.id("sector-1"));
sector.click();

At this page selenium does not click After click system must open this page enter image description here

More detail html code

Upvotes: 0

Views: 485

Answers (3)

Andrii Dudchenko
Andrii Dudchenko

Reputation: 91

I decide my problem.

WebDriverWait wait = new WebDriverWait(webDriver, 10);
    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"sector-2:canvas\"]")));

    WebElement svgObject = webDriver.findElement(By.xpath("//*[@id=\"sector-2:canvas\"]"));
    Actions builder = new Actions(webDriver);
    builder.click(svgObject).build().perform();

Upvotes: 0

Andersson
Andersson

Reputation: 52685

Seems that you try to interact with object inside a <svg> element. If so, you cannot manage it's child elements simply using click() method.

Try this instead:

WebElement svgObject = driver.findElement(By.xpath("//polygon[@id='sector-1:canvas']"));
Actions builder = new Actions(driver);
builder.click(svgObject).build().perform();

Upvotes: 1

Mosam Mehta
Mosam Mehta

Reputation: 1668

Use below XPath :

WebElement sector = webDriver.findElement(By.xpath("//g[@id='sector-1']/polygon"));
sector.click();

OR

WebElement sector = webDriver.findElement(By.xpath("//polygon[@id='sector-1:canvas']"));
sector.click();

Upvotes: 0

Related Questions