DOM structure of Name column:
<div comp-id="362" aria-colindex="2" tabindex="-1" col-id="Name" role="gridcell"
style="left: 0px; width: 150px; line-height: 18px; padding: 8px; display: inline-block; white-space: nowrap; overflow:hidden; margin-right: 20px;">
<span>
<span>
"Sam Michaels" == $0
<span>
<br>
<span style="font-size: 1.2rem">Male</span>
</span>
I got 4 columns: Name, Gender, Location and Occupation.
Name column xpath: //div[@col-id='Name'
]
Inside Name column, every row has two things: "Name" (Large font) and "Age" (Small font). How to validate font sizes in that "Name" column?
CodePudding user response:
You should be able to use the WebElement#getCssValue(propertyName)
method, e.g. like this:
By findBy = By.xpath("//div[@col-id='Name']")
WebElement element = driver.findElement(findBy);
String fontSizeCssValue = element.getCssValue("font-size");
System.out.println(fontSizeCssValue );