I am unable to click the close icon in panel window using selenium webdriver

时间:2016-04-07 10:28:19

标签: selenium selenium-webdriver webdriver

I am trying to close the panel window using selenium webdriver. But I can't handle this. When I click on close button, I got an exception as "Unable to locate Element".

HTML code:-

<a class="ui-dialog-titlebar-close ui-corner-all" role="button" href="#"> <span class="ui-icon ui-icon-closethick">close</span>

Here is the code:

    WebElement containerEle = driver.findElement(By.tagName("iframe"));
    driver.switchTo().frame(containerEle);
    //driver.findElement(By.cssSelector("span.ui-icon.ui-icon-closethick")).click();
    driver.findElement(By.xpath(".//*[@id='ext-gen4']/div[4]/div[1]/a/span")).click();

And find the attachment for your reference. enter image description here

Thanks in advance.

1 个答案:

答案 0 :(得分:0)

尝试点击JavascriptExecutor: -

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);

element是您要点击的Web元素