简体   繁体   English

如何使用 Selenium 和 Java 在 Krypton 中检查属性 aria-disabled 的值是真还是假?

[英]How do I check the value of the attribute aria-disabled as true or false in Krypton using Selenium and Java?

I tried:我试过:

ExpectedConditions.presenceOfElementLocated(By.cssSelector("[id='StandardSave'][aria-disabled='true']" 

but still won't work.但仍然无法正常工作。

To check the value of the attribute aria-disabled you you have to induce WebDriverWait for the visibilityOfElementLocated() and you can use either of the following Locator Strategies :要检查属性aria-disabled的值,您必须为visibilityOfElementLocated()引入WebDriverWait ,您可以使用以下任一定位器策略

  • Using id :使用id

     System.out.println(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.id("StandardSave"))).getAttribute("aria-disabled"));
  • Using cssSelector :使用cssSelector

     System.out.println(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#StandardSave"))).getAttribute("aria-disabled"));
  • Using xpath :使用xpath

     System.out.println(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='StandardSave']"))).getAttribute("aria-disabled"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Selenium Java 使用 Krypton 捕获屏幕截图 - How to capture a screenshot using Krypton using Selenium Java Java如何检查arraylist对象并使其为true / false? - Java How do i check for an arraylist object and make it true/false? 如何在Java的IF语句中检查方法是返回true还是false? - How do I check if a method returns true or false in an IF statement in Java? 如何检查方法是否返回 true 或 false? - How do I check if a method returns a true or false? 在Selenium WebDriver中使用Java在ID或任何属性中不存在值时如何从禁用的文本字段中获取值 - How to get value from a disabled text field when the value is not present in ID or in any attribute using Java in Selenium WebDriver 如何检查Java中的所有布尔值是真还是假? - How to check if all boolean are true or false in Java? 如何使用Selenium Java提取HTML值? - How do I extract a HTML value using selenium java? Selenium / Java:如何为 aria-selected=false 的元素编写元素定位器 - Selenium / Java : How to write element locator for an element with aria-selected=false Java SQL +检查是/否 - java sql + check true/false 如何在Selenium-java中使用xpath获取表中禁用属性的大小 - how to get the size of disabled attribute in table with xpath in selenium-java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM