Skip to content

Instantly share code, notes, and snippets.

View FriendlyTester's full-sized avatar

Richard Bradshaw FriendlyTester

View GitHub Profile
try
{
requiredRow = _tableRows.First(d => d.FindElement(By.XPath(string.Format("td[{1}"]))).Text == knownValue);
}
return requiredRow.FindElement(By.XPath(string.Format("td[{0}]", FindColumnIndex(columnName))));
@FriendlyTester
FriendlyTester / gist:6982140
Created October 14, 2013 21:01
RemoteWebDriver Screenshot
public class ScreenShotRemoteWebDriver : RemoteWebDriver, ITakesScreenshot
{
public ScreenShotRemoteWebDriver(Uri remoteAddress, ICapabilities desiredCapabilities)
: base(remoteAddress, desiredCapabilities)
{
}
public Screenshot GetScreenshot()
{
// Get the screenshot as base64.
Screenshot ss = ((ITakesScreenshot)webDriver).GetScreenshot();
string screenshot = ss.AsBase64EncodedString;
byte[] screenshotAsByteArray = ss.AsByteArray;
ss.SaveAsFile(@"C:\Temp", System.Drawing.Imaging.ImageFormat.Jpeg);
webDriver = new ScreenShotRemoteWebDriver(new Uri(remoteServer), capabilities);
public abstract class DefaultPage
{
protected IWebDriver WebDriver { get; set; }
public LynxDefaultPage(IWebDriver webDriver)
{
WebDriver = webDriver;
}
}
//Inherit the DefaultPage.
public class BlogObject : DefaultPage
{
//Two parameters, base in your driver, and also the timeout for the page to finish loading.
public BlogObject(IWebDriver webDriver, double timeout)
: base(webDriver) //Pass the driver to the base class.
{
//Initiate the locators dictionary, and assign to private parameter.
_locators = Locators();
BlogObject blogObject = new BlogObject (webDriver, 60);
@FriendlyTester
FriendlyTester / gist:9387475
Created March 6, 2014 11:09
IWebDriver Screenshot Extension
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using System;
using System.Drawing.Imaging;
namespace Richard.WebDriverExtensions
{
public static class WebDriverExtensions
{
/// <summary>
@FriendlyTester
FriendlyTester / gist:9387503
Created March 6, 2014 11:11
Using TakeScreenshot Extension
webDriver.TakeScreenshot(@"C:\Temp\Richard.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);