如何使用 PowerShell 删除 Azure 资源的所有标签?

powershellmicrosoft technologiessoftware & coding

我们可以使用 Selenium webdriver 的 getAttribute 方法获取 Web 元素的属性值,然后将需要获取值的属性作为参数传递给该方法。

在 HTML 代码中,元素由属性及其值组成,这些属性和值以键值对的形式定义。让我们尝试获取页面中以下元素的类 – 标题 −

语法

WebElement t =driver.findElement(By.xpath("//li[text()='About Tutorialspoint']"));
String s = t.getAttribute("class");

示例

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
public class AttribtValue{
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver",
         "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe");
      WebDriver driver = new FirefoxDriver();
      //隐式等待
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL 启动
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // 使用 xpath 识别元素
      WebElement t =driver.
      findElement(By.xpath("//li[text()='About Tutorialspoint']"));
      //获取类属性值
      String s = t.getAttribute("class");
      System.out.println("Class attribute value is : " + s);
      driver.close();
   }
}

输出


相关文章