【问题标题】:I want to close a popup. driver is unable to locate the cross(X) in the popup我想关闭一个弹出窗口。驱动程序无法在弹出窗口中找到十字(X)
【发布时间】:2017-08-29 15:49:00
【问题描述】:

我无法单击或关闭弹出窗口。没有其他元素可以定位并关闭窗口。下面是定位窗口时引发的错误。 我正在使用代码:

WebElement noteDisplayWindow = driver.findElement(By.xpath("//body/div[2]/div[1]/button/span"));
noteDisplayWindow.click();

或者使用css选择器

WebElement noteDisplayWindow1=driver.findElement(By.cssSelector("button[type='button'][class='ui-button']"));
noteDisplayWindow1.click();

当我运行 CSS 选择器时出现此错误。

org.openqa.selenium.WebDriverException:未知错误:

Element <span class="abc xyz qwe yui"></span> is not clickable at point (968, 150). Other element would receive the click: <div class="xyz1[enter image description here][1] abc1 sdsd"></div>

(会话信息:chrome=56.0.2924.87) (驱动程序信息:chromedriver=2.28.455520 ,platform=Windows NT 6.1.7601 SP1 x86_64)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:67 毫秒 构建信息:版本:'未知',修订:'5234b32',时间:'2017-03-10 09:00:17 -0800'

【问题讨论】:

  • "...无法单击或关闭弹出窗口":什么弹出窗口?请提供一些 HTML。
  • 当我点击一个链接时它会弹出。它没有任何按钮。只是关闭(X 符号)present 来关闭弹出窗口。

标签: selenium selenium-webdriver css-selectors selenium-chromedriver


【解决方案1】:

试试这个

WebElement myDynamicElement=driver.findElement(By.cssSelector("button[type='button'][class='ui-button']"));

new Actions(driver).moveToElement(myDynamicElement).click().perform();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-10
    • 2018-07-15
    • 2014-10-09
    相关资源
    最近更新 更多