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

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) 
主站蜘蛛池模板: 永德县| 宁武县| 伊宁县| 嘉义县| 嘉善县| 徐闻县| 吴堡县| 张掖市| 常山县| 扬州市| 蓬莱市| 新干县| 安远县| 连城县| 岳西县| 奈曼旗| 江源县| 乐平市| 邵阳县| 嘉鱼县| 余干县| 霍林郭勒市| 宝丰县| 梨树县| 贡山| 河东区| 白水县| 临桂县| 乌审旗| 德钦县| 广昌县| 通渭县| 肥西县| 龙里县| 石台县| 彭山县| 锡林郭勒盟| 宁阳县| 太原市| 尉氏县| 武乡县|