The RemoteWebDriver
must be augmented before you can use the screenshot capability. As you have no doubt already found, attempting to cast without augmenting results in an exception.
WebDriver driver = new RemoteWebDriver( ... );
driver = new Augmenter().augment( driver );
( (TakesScreenshot)driver ).getScreenshotAs( ... );
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…