- Selenium WebDriver 3 Practical Guide
- Unmesh Gundecha Satya Avasarala
- 128字
- 2021-08-13 16:08:10
The getSize() method
The getSize method can also be called on all the visible components of HTML. It will return the width and height of the rendered WebElement. The API syntax of the getSize() method is as follows:
Dimension getSize()
The preceding method doesn't take any input parameters, and the return type is a class instance named Dimension. This class contains the width and height of the target WebElement. The following is the code to get the width and height of the Search box:
WebElement searchBox = driver.findElement(By.name("q"));
System.out.println("Size of the box is: "
+ searchBox.getSize());
The output for the preceding code is the width and height of the Search box, as shown in the following screenshot:
Size of the box is: (281, 40)
推薦閱讀
- Hands-On Chatbot Development with Alexa Skills and Amazon Lex
- Oracle SOA Suite 11g Performance Tuning Cookbook
- 網絡安全技術與解決方案(修訂版)
- 互聯網安全的40個智慧洞見:2015年中國互聯網安全大會文集
- Mastering TypeScript 3
- Building RESTful Web services with Go
- 智慧光網絡:關鍵技術、應用實踐和未來演進
- Mastering Dart
- OMNeT++與網絡仿真
- 搶占下一個智能風口:移動物聯網
- 通信十年:擁抱互聯網
- 6G:面向2030年的移動通信
- 精通SEO:100%網站流量提升密碼
- 黑客與反黑工具使用詳解
- 網絡互聯技術(理論篇)