Home > Software design >  How to validate the height of the element in % value in selenium using Java
How to validate the height of the element in % value in selenium using Java

Time:12-30

I got the height of the element in px values by using: element.getCssValue("height")

But by using this, i got the height as: Height: 560px

But I need to get the height as: Height: 100% Or like Height: 50%

CodePudding user response:

you mean you want to replace px with %? if yes then use string replace method

CodePudding user response:

Something like this will get the percentage of the element in relation to the height of the window:

double heightPercentage = element.getCssValue("height") / driver.Manage().Window.Size.Height;
  • Related