/**
  * Converts a text selector to a By object.
  *
  * Tries to find magic expressions (css=#foo, xpath=//div[@id="foo"], id=foo, name=q, class=active).
  *
  * @return By|string returns a By instance when magic matched, the string otherwise
  */
 protected function parseSelector($text)
 {
     if (0 === strpos($text, 'id=')) {
         return By::id(substr($text, 3));
     }
     if (0 === strpos($text, 'xpath=')) {
         return By::xpath(substr($text, 6));
     }
     if (0 === strpos($text, 'css=')) {
         return By::css(substr($text, 4));
     }
     if (0 === strpos($text, 'name=')) {
         return By::name(substr($text, 5));
     }
     if (0 === strpos($text, 'class=')) {
         return By::className(substr($text, 6));
     }
     return $text;
 }