`ICapabilities caps = ((RemoteWebDriver)driver).Capabilities;
string browserName = string.Empty;
browserName = caps.GetCapability("browserName").ToString();
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
// element to be highlighted
element = driver.FindElement(By.XPath("//input[@id='ctl00_MainContent_txtAdd2']"));
js.ExecuteScript("arguments[0].style.border='3px solid red'", element);
Screenshot image = ((ITakesScreenshot)driver).GetScreenshot();
string testMethodName = TestContext.CurrentContext.Test.Name;
image.SaveAsFile("C:/temp/" + browserName + testMethodName + ".png", ScreenshotImageFormat.Png);
Screenshot on Highlighted Element in Chrome-Work Fine
Unable to Screenshot on Highlighted Element in Firefox
我是否无法在Firefox中突出显示和截屏,但是在Chrome中可以正常工作?