官术网_书友最值得收藏!

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) 
主站蜘蛛池模板: 清镇市| 余干县| 且末县| 黎川县| 嘉定区| 绍兴县| 晋中市| 九龙城区| 迁安市| 曲松县| 丰顺县| 烟台市| 通州区| 渝中区| 濉溪县| 迭部县| 出国| 洪江市| 拉萨市| 万宁市| 交城县| 侯马市| 荣成市| 黄山市| 莆田市| 韶关市| 咸阳市| 靖边县| 休宁县| 绥中县| 郯城县| 西充县| 望城县| 凤阳县| 昌吉市| 天长市| 宁蒗| 合川市| 庄河市| 和静县| 韶山市|