【问题标题】:Katalon Selenium Element is visible but displayed is falseKatalon 硒元素可见但显示为假
【发布时间】:2018-09-06 02:25:12
【问题描述】:

我正在尝试使用带有 selenium/katalon 的 vuetify 在 vue js 中单击一个按钮。它在 UI 中完全可见,但仍然可以单击。我可以找到没有问题的元素,但是单击它会返回一个元素不可见错误。我尝试了各种solutions,包括:

  • 用javascript点击(js执行点击脚本但不点击按钮)
  • 使用 Action 类移动到元素然后点击它(它不会移动到元素)
  • 聚焦并滚动到元素
  • 等待
  • 切换到活动元素、默认内容和最大化窗口
  • 没有不显示的父元素

在调试时我注意到以下内容:

// Able to find element with no issues
WebDriver driver = DriverFactory.getWebDriver();
String xPathForButton = "//div[@id='validationStepper']/div[3]/div[1]/div/div[2]/fieldset/div[1]/div/div/div/div[3]/button[1]";
def element = driver.findElement(By.xpath(xPath));
// Element not visible exception
element.click();

KeywordUtil.logInfo('X: ' + element.getLocation().x); // Prints 0
KeywordUtil.logInfo('Y: ' + element.getLocation().y); // Prints 0
KeywordUtil.logInfo('Element is enabled: ' + element.isEnabled()); // Prints true
KeywordUtil.logInfo('Element is displayed: ' + element.isDisplayed()); // Prints false

我需要使用 xpath 来找到这个元素。有人可以帮助我了解如何正确检测并点击此元素吗?

【问题讨论】:

  • 试图点击哪个元素?你的代码试验?
  • 按钮。我没有问题找到它。但是当我点击它时,它会抛出一个不可见的异常,即使它是可见的。

标签: javascript java selenium groovy katalon-studio


【解决方案1】:

问题原来是在运行时父元素是display: none。虽然我最初没有显示任何父元素,但 CSS 动态更改,导致这种情况发生。我进行了更正,之后元素可见。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-16
    • 2015-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-23
    相关资源
    最近更新 更多