[英]facing issue while getting size of web element into a integer variable
類型不匹配:無法從尺寸轉換為整數。
int sizeOfServiceInstanceRow = driver.findElement(By.xpath("//table/tbody/tr[4]/td/table/tbody/tr")).getSize();
我們應該在sizeOfServiceInstanceRow
變量中確定Web元素的大小。
從selenium docs中, getSize
返回一個Dimension
對象(其中包含height和width屬性),您不能直接將其int
轉換為int
類型。
如果您對獲取元素的高度和寬度感興趣,則可以執行以下操作。
Dimension elemDimension = driver.findElement(By.xpath("//table/tbody/tr[4]/td/table/tbody/tr")).getSize();
int height = elemDimension.getHeight();
int width = elemDimension.getWidth();
請參閱docs https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebElement.html#getSize--
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.