- Selenium WebDriver 3 Practical Guide
- Unmesh Gundecha Satya Avasarala
- 128字
- 2021-08-13 16:08:11
The isDisplayed() method
The isDisplayed action verifies whether an element is displayed on the web page and can be executed on all the WebElements. The API syntax for the isDisplayed() method is as follows:
boolean isDisplayed()
The preceding method returns a Boolean value specifying whether the target element is displayed on the web page. The following is the code to verify whether the Search box is displayed, which obviously should return true in this case:
@Test
public void elementStateExample() {
WebElement searchBox = driver.findElement(By.name("q"));
System.out.println("Search box is displayed: "
+ searchBox.isDisplayed());
}
The preceding code uses the isDisplayed() method to determine whether the element is displayed on a web page. The preceding code returns true for the Search box:
Search box is displayed: true
推薦閱讀
- 物聯網與北斗應用
- 數據通信網絡實踐:基礎知識與交換機技術
- 社交電商運營策略、技巧與實操
- WordPress 5 Complete
- 面向云平臺的物聯網多源異構信息融合方法
- 面向物聯網的嵌入式系統開發:基于CC2530和STM32微處理器
- 區塊鏈輕松上手:原理、源碼、搭建與應用
- Yii Application Development Cookbook(Second Edition)
- Building RESTful Web services with Go
- C/C++串口通信:典型應用實例編程實踐
- Kong網關:入門、實戰與進階
- 物聯網頂層設計與關鍵技術
- 物聯網的機遇與利用
- 計算機通信網絡安全
- SEO攻略:搜索引擎優化策略與實戰案例詳解