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

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) 
主站蜘蛛池模板: 阿坝县| 洛宁县| 抚州市| 鄄城县| 南陵县| 吉安县| 罗源县| 平度市| 大庆市| 土默特左旗| 沾益县| 无锡市| 寿阳县| 台中县| 五家渠市| 巨鹿县| 新兴县| 宣城市| 黄大仙区| 洞口县| 阳曲县| 信宜市| 柳河县| 诸暨市| 澎湖县| 荥经县| 彰武县| 梧州市| 高阳县| 郯城县| 类乌齐县| 通州市| 英德市| 搜索| 芜湖县| 沂南县| 阿坝县| 年辖:市辖区| 广水市| 浦江县| 于都县|