Robinson–Trautman spacetimes with an electromagnetic field in higher dimensions