當前位置: 首頁>>代碼示例>>C#>>正文


C# FirefoxDriver.GetScreenshot方法代碼示例

本文整理匯總了C#中OpenQA.Selenium.Firefox.FirefoxDriver.GetScreenshot方法的典型用法代碼示例。如果您正苦於以下問題:C# FirefoxDriver.GetScreenshot方法的具體用法?C# FirefoxDriver.GetScreenshot怎麽用?C# FirefoxDriver.GetScreenshot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenQA.Selenium.Firefox.FirefoxDriver的用法示例。


在下文中一共展示了FirefoxDriver.GetScreenshot方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DoIt

        static void DoIt(string path)
        {
            string uri = @"file:///" + path;

            var d = new FirefoxDriver();
            d.Manage().Window.Size = new Size(2000, 2000);
            d.Navigate().GoToUrl(Path.Combine(uri, "a3.html"));

            var s = d.GetScreenshot();
            s.SaveAsFile(Path.Combine(path, "a3.png"), ImageFormat.Png);

            d.Quit();
        }
開發者ID:mt-inside,項目名稱:mka3,代碼行數:13,代碼來源:Program.cs

示例2: SeleniumTets

        public void SeleniumTets()
        {
            using (var driver = new FirefoxDriver(new FirefoxBinary("D:\\Program Files\\Mozilla Firefox\\firefox.exe"), new FirefoxProfile()))
            //using (var driver = new EdgeDriver())
            {
                //System.Threading.Thread.Sleep(10000);
                driver.Manage().Window.Maximize();
                driver.Navigate().GoToUrl("http://localhost:5956");

                //driver.Navigate().GoToUrl("http://localhost:5956");
                driver.GetScreenshot().SaveAsFile("data.png",ImageFormat.Png);
                driver.FindElements(By.TagName("a")).First(a => a.Text.Equals("About", StringComparison.InvariantCultureIgnoreCase)).Click();
                Assert.AreEqual(driver.Url, "http://localhost:5956/Home/About");
            }
        }
開發者ID:Stefan-Yordanov,項目名稱:TeamCitySeleniumTests,代碼行數:15,代碼來源:UnitTest1.cs

示例3: TestMethod1

 public void TestMethod1()
 {
     var driver = new FirefoxDriver();
     try
     {
         driver.Navigate().GoToUrl("http://docs.seleniumhq.org/oops");
         driver.FindElement(By.Id("q")).Click();
         driver.Keyboard.SendKeys("Hello World!");
         driver.Keyboard.PressKey(Keys.Enter);
     }
     catch (Exception e)
     {
         var ss = driver.GetScreenshot(); 
         ss.SaveAsFile("failed-test-case.png", ImageFormat.Png);
         driver.Close();
         throw;
     }
 }
開發者ID:Jetabroad,項目名稱:DotNetUserGroup,代碼行數:18,代碼來源:UnitTests.cs

示例4: StartScreenshotting

        public void StartScreenshotting(object parameters)
        {
            var parameter = parameters as object[];
            InstanceInfo instanceInfo = parameter[0] as InstanceInfo;
            DataTable urls = parameter[1] as DataTable;

            Log("Starting firefox...");
            FirefoxProfile ffProfile = new FirefoxProfile();
            JavaScriptError.AddExtension(ffProfile);

            using (var browser = new FirefoxDriver(ffProfile))
            {
                string targetDirectory = CreateTargetDirectory(instanceInfo);
                List<JavaScriptError> jsErrors = new List<JavaScriptError>();

                for (int i = 0; i < urls.Rows.Count; i++)
                {
                    try
                    {
                        Guid nodeGuid = (Guid)urls.Rows[i]["NodeGUID"];
                        Uri url = new Uri(instanceInfo.Url, "getdoc/" + nodeGuid);

                        Log("Screenshotting [{0}/{1}]: {2}", i, urls.Rows.Count, nodeGuid);

                        browser.Navigate().GoToUrl(url);
                        string fileName = GetFileName(targetDirectory, browser.Url);
                        browser.GetScreenshot()
                            .SaveAsFile(fileName, ImageFormat.Jpeg);

                        jsErrors.AddRange(JavaScriptError.ReadErrors(browser));
                    }
                    catch (Exception e)
                    {
                        Log("Exception: {0}", e.Message);
                    }
                }

                SaveJavaScriptErrorsToFile(jsErrors, targetDirectory);
                Log("Screenshotting finished.");
                browser.Close();
            }
        }
開發者ID:kordys,項目名稱:KInspector,代碼行數:42,代碼來源:ScreenshotterModule.cs


注:本文中的OpenQA.Selenium.Firefox.FirefoxDriver.GetScreenshot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。