gpt4 book ai didi

javascript - 验证 moveToElement 或 clickandHold 是否正常工作

转载 作者:太空宇宙 更新时间:2023-11-04 10:01:16 24 4
gpt4 key购买 nike

我做了几种方法来执行悬停操作,但我需要一种方法来验证该方法是否有效,如果不是这种情况,请使用其他方法。

我使用此代码进行验证,但不起作用:

return zQuery(arguments[0]).attr('data-functionize-hover'); 

我认为有一个脚本可以跟踪 dom 是否发生变化,但不确定这是否可能。

谢谢!!

最佳答案

要验证移动到元素,您可以尝试实现以下场景:

  1. 使用 Actions 执行移动到元素操作(import org.openqa.selenium.interactions.Actions;)

    WebElement elToHover = driver.findElement(By.id("add_element_id_here"));
    Actions actions = new Actions(driver);
    actions.moveToElement(elToHover).perform();
  2. 验证更改内容

如果您需要检查我们在步骤 1 中悬停的元素的某些属性:

assertEquals(elToHover.getAttribute('attribute-name-you-want-to-check', "value you expext");

如果您需要检查其他一些元素:

WebElement anotherEl = driver.findElement(By.id("add_another_element_id_here"));
assertTrue(anotherEl.isDisplayed());

关于javascript - 验证 moveToElement 或 clickandHold 是否正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53448148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com