0

So I currently have an ElementFinder which retrieves the following element:

<div class="label-div" style="width: 100%; height: 100%; font-family: Arial; margin-left: -43px; visibility: visible; font-size: 0.8em;" xmlns="http://www.w3.org/1999/xhtml">Helpdesk</div>

My question is how would I go about checking that the font-size equals a certain value?

This is close to the problem in question 2664045, however this is working with ElementFinders rather than Elements and none of the replies seemed to go over the option for this

I have tried element.getCssValue('font-size')).toBe('0.8em');, However this fails as it retrieves the font-size in pixels, rather than em

AleksW
  • 703
  • 3
  • 12
  • 1
    check this out https://stackoverflow.com/questions/2664045/how-to-get-an-html-elements-style-values-in-javascript – holydragon Nov 28 '18 at 10:24
  • Possible duplicate of [How to get an HTML element's style values in javascript?](https://stackoverflow.com/questions/2664045/how-to-get-an-html-elements-style-values-in-javascript) – tomerpacific Nov 28 '18 at 10:32
  • It did help however I'm not working with an 'Element' here, rather an ElementFinder so it is slightly different, but this got me close, just needed to use `.getCssValue()` rather than `.css` – AleksW Nov 28 '18 at 10:36

3 Answers3

1

Try this:

element.getCssValue('font-size')).toBe('0.8em');
Anandu S
  • 159
  • 8
0

I ended up using the following solution, although not ideal, it works:

expect(hp.sunburstFirstChildTextElement.getAttribute('style')).toContain('font-size: 0.8em');
AleksW
  • 703
  • 3
  • 12
0

Try this is it returns Pixels as convert em to pixel

element.getCssValue('font-size')).toBe(0.8*10+'px');
Rao
  • 397
  • 1
  • 12