Skip to content
Advertisement

How add two values[1,2 elements] and verify its equal to result[3 element]

I need to verify if the sum of two elements is equal to the result shown on the UI. Below is the html structure for the three elements and need to do the calculation on the h1 tags. enter image description here

Below is the code I am trying to execute but nothing comes up in the test. The test runs and passes but nothing in the body.

JavaScript

Also, if someone could point out why it isn’t working, would really appreciate it.

Advertisement

Answer

You can directly invoke text, convert them to numbers and add it like this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement