50 gallon unit. Great hot water to start but by the end of the shower. Does this indicate the top or bottom heating element is bad? AND how can I test the elements to make sure? Any insights on replacing the element?

Bottom element is probably bad: top heats water at top where the pipe is until set point is reached, then bottom element comes on. if you want to check without electrical meter, turn off power and let appliance cool down some.. while power is off, disconnect wires on top element and cap with a wire nut. have someone turn on breaker while you watch your electrical meter where power comes in house. meter will spin because of other load on house. now turn off power and reconnect wires to element. repeat turning on breaker and watching meter spin-should spin quite a bit faster than before. now turn off breaker again and disconnect bottom element and cap wires. turn on power and watch meter; when it slows down, top element is at set point. try to remember how fast meter is spinning when top element was on. reconnect bottom element and repeat breaker process and watching meter. if meter still spins slow, bottom element is not working. bottom element is storage section of water heater- top element only heats about 1/3 of area of total heater, with bottom element doing the rest, thus low hot water capacity. if you don’t have patience to do this, but an ammeter that will clip around the wire. checking either wire on each element will indicate which one works when called for– you can also use an ohm meter to check elements- good element will have measurable resistance (3500 to 4500 ohms typically) while bad element will have infinite resistance.
To change element, disconnect power, shut off water to heater, drain tank to just below element that is bad, either screw element out using proper size socket or remove bolts holding element in, then reverse above steps to install new element. open water valve to heater to check for leaks, vent air from unit thru t&p valve and turn on power. ALWAYS FILL TANK WITH WATER AND VENT AIR FROM TANK BEFORE TURNING ON POWER!

After turning off the power, and, disconnecting the four terminals, which feed power to the two elements, making sure to mark the leads, so, you can get them back in the right places, you can check the elements with an ohmmeter. They should read very low resistance. if the resistance is more than 10 or 20 ohms, that element is burned out. NEVER connect an element to power, unless it is installed in the heater, and, the heater has water in it. It will blow the element, with explosive force. The elements, once disconnected, are installed in a socket with a fitting that can be removed with a pipe wrench. A new element needs proper sealer around it, before insertion in the hole.