首页 > 解决方案 > PowerShell Selenium 代码等待元素属性具有特定值

问题描述

在 PowerShell 代码中,我需要等到 Web 元素的属性更改其值。我正在使用 PowerShell 和 Selenium WebDriver 编写自动化测试。当我按下视频播放器的播放按钮时。VideoLoaded div 的 aria-valuenow 属性将其值从 0 更改为其他值。我需要WebDriver等到div的aria-valuenow属性值不等于0。

以下是用 C# 编写的相同代码的示例,但我不知道如何在 PowerShell 中编写它。

waitForElement.Until((Driver) => Driver.FindElement(By.CssSelector("div[class='loaded']")).GetAttribute("aria-valuenow") != "0");

我已经编写了以下 powershell selenium webdriver 代码来等待使用预期的条件元素是可点击的,但无法找到一种方法来完成等待属性值更改的方法。请帮忙。谢谢

$seleniumWait.Until([OpenQA.Selenium.Support.UI.ExpectedConditions]::ElementToBeClickable([OpenQA.Selenium.By]::XPath("//span[text()='Recognise the importance of air']")));

标签: c#powershellselenium-webdriver

解决方案


推荐阅读