Make byClass work as expected with PhantomJS

getElementsByClassName() may return a function when running under PhantomJS, while this is not the case with Safari or Firefox.