How to verify bold appearance of a certain field in selenium

java, selenium

Solution

You can check the font-weight using the `style()` method (assuming you are actually using Selenium-Webdriver).

So say you have HTML like:

<body>
  <div id='1' style='font-weight:normal'>
    <div id='2' style='font-weight:bold'>Field Label</div>
    <div id='3'>Field</div>
  </div>
</body>

You can do the following to check the font-weight of the field label div (the following is in Ruby, though similar should be possible in the other languages).

el = driver.find_element(:id, "2")
if el.style('font-weight') >= 700
  puts 'text is bold'
else
  puts 'text is not bold'
end 

Problem

I am trying to automate a manual script (using selenium in java) to check the bold appearance of a certain field(label:which stands for mandatory field) on a web page . what can be the possible selenium java functions to verify the bold appearance of certain element(In class there is no information about the appearance)

Original source

Related problems