本文整理汇总了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();
}
示例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");
}
}
示例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;
}
}
示例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();
}
}