I found the following online...usually its the sensor itself but this is how you would properly diagnose...
How does a mechanic diagnose the P0059 code?
To start off, I will usually do a quick visual inspection of the oxygen sensor harnesses for any obvious signs of damage. If there is any visible damage found it must be corrected before further diagnostics can be performed. The damage is likely the source of the trouble code setting.
If no damage is found I will measure the resistance of the heater circuit in the oxygen sensor itself. The service manual will have a specification for what the resistance should be. If the sensor reads out of specification you have found the problem.
If the sensor checks out ok I will connect a test lamp into the vehicle side of oxygen sensor heater circuit (as opposed to the oxygen sensor harness itself). If the test light shines bright it confirms that the heater circuit is functioning normally.
If the sensor tests normal and the vehicle side tests ok with the test light, it is time to take a close look at the connection between the vehicle side of the harness and the oxygen sensor harness.
There could be corrosion or damage to the terminals that is causing a poor connection and causing P0059 to set.
Common mistakes when diagnosing the P0059 code
By far, the most common “mistake” is simply replacing the bank 2 sensor 1 oxygen sensor without performing and diagnostics at all. This happens a lot because the vast majority of the time it is the sensor itself that has failed. The sensor is heated to 500 degrees fahrenheit every time the car is turned on. As you could imagine that is a lot of stress. It’s a high failure item so it can be easy to get lazy and just replace the sensor.
Another common mistake is measuring the wrong terminals in the connectors. It is important to know how to read the wiring diagrams so you know you are measuring the correct circuits.