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

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) 
主站蜘蛛池模板: 资溪县| 红安县| 巢湖市| 昌江| 河北省| 克拉玛依市| 徐汇区| 霸州市| 榆中县| 开阳县| 泸西县| 洛扎县| 陇川县| 阿拉善左旗| 闽清县| 武平县| 长岭县| 诸暨市| 清镇市| 遂平县| 镶黄旗| 偃师市| 二手房| 清涧县| 许昌县| 闻喜县| 内乡县| 贞丰县| 九台市| 耒阳市| 龙州县| 龙江县| 丽水市| 永德县| 长岭县| 金华市| 翼城县| 西乌珠穆沁旗| 广德县| 商都县| 龙江县|