1
votes

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.

2
please post your HTML code so we can help you better ... check if there is any frame presentShubham Jain
Please provide page source HTML..Shubhasmit Gupta
<a class="ui-dialog-titlebar-close ui-corner-all" role="button" href="#"> <span class="ui-icon ui-icon-closethick">close</span> @ShubhamJainvsreekanth

2 Answers

0
votes

Try click using JavascriptExecutor :-

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

element is the WebElement on which you want to click

0
votes

I would try to click on the <a> tag instead:

driver.switchTo().frame(driver.findElement(By.tagName("iframe")));
driver.findElement(By.cssSelector(".ui-dialog-titlebar-close")).click();