The formation of a stagnant cap on a bubble attached to a microelectrode is studied by means of numerical simulation including both thermo- and solutocapillary effects. Recently, strong Marangoni flow in an electrolyte around electrogenerated bubbles was observed by Yang et al.  and Massing et al. . High local current density above the electrode led to Ohmic heating of the electrolyte near the bubble foot and resulted in thermocapillary convection. However, the experimentally observed Marangoni convection can be predicted better if a stagnant cap of surfactants on the top of the bubble is assumed. The present work provides evidence that supports this hypothesis and simulates the stagnant cap utilizing two methods. In the first method, a critical stagnation angle θ s, which marks the border of the stagnant cap, is specified. At the top of the bubble above the stagnation θ s the interface motion is suppressed whereas at the bottom of the bubble below the stagnation θ s the thermocapillary effect dominates. In the more extensive second method, a transport equation for the surfactant concentration on the bubble interface is included. In this method, the thermo- and solutocapillary effects compete along the entire interface of the bubble. As a result, the top part of the bubble interface will stagnate. We quantify the rigidity of the bubble interface by a dimensionless number, the elasticity number. This elasticity number is the ratio of the solutocapillary stress due to surfactant variation to the thermocapillary stress due to temperature variation. The relevant temperature variation is due to Ohmic heating and is observed to scale with the square of the potential difference. As a consequence, the Marangoni velocity is also found to scale with the square of the potential difference. Additionally, the forces acting on the bubble before detachment are analysed. Special attention is given to the Marangoni force that is more dominant than reported previously because we included the force caused by the uneven pressure distribution along the bubble interface. The pressure distribution is uneven due to a secondary Marangoni vortex in the wedge between the bubble and the electrode. Furthermore, a general framework for Marangoni numbers is introduced to quantify the effect of each specific source of surface stress variation upon the spatial distribution of each variable governed by a convection-diffusion equation.