无法截屏Mozilla中突出显示的元素,但能够截屏Chrome中突出显示的元素

时间:2019-05-28 07:53:30

标签: c# selenium firefox

`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中可以正常工作?

0 个答案:

没有答案