Skip to content

Instantly share code, notes, and snippets.

View nadvolod's full-sized avatar
🏖️
Just living the good life

Nikolay Advolodkin nadvolod

🏖️
Just living the good life
View GitHub Profile
@nadvolod
nadvolod / gist:c4fb9a41387789818b16
Created January 22, 2016 00:28
Sample code for an equivalence partition example
if(integerEntered >= 1 && integerEntered <= 5)
DisplayMessage(“Success”);
@nadvolod
nadvolod / gist:6029c9f93be7bc346ec7
Created February 19, 2016 13:08
Sample code that works with Nunit to prepare it for parallelization
using NUnit.Framework;
using OpenQA.Selenium.Firefox;
namespace ParallelLocal
{
[TestFixture]
public class ParallelLocal
{
[Test]
public void Test1()
@nadvolod
nadvolod / gist:8af1bb1dd39c5a684382
Created February 19, 2016 13:34
Two parallel Nunit tests ready to be ran
using NUnit.Framework;
using OpenQA.Selenium.Firefox;
namespace ParallelLocal
{
[TestFixture]
[Parallelizable]
public class ParallelLocal
{
[Test]
@nadvolod
nadvolod / gist:2841fa4ccb24ac4b26ff
Created February 23, 2016 13:54
Sample Selenium Webdriver test that is ready to be ran in BrowserStack in parallel mode.
[TestFixture]
[Parallelizable]
public class BrowserstackTest2
{
private IWebDriver driver;
[SetUp]
public void Init()
{
DesiredCapabilities capability = DesiredCapabilities.Firefox();
@nadvolod
nadvolod / gist:b1d183f71e5df9a7edcf
Last active June 30, 2018 19:24
A Selenium Webdriver C# test that is ready to be ran in parallel mode in BrowserStack's cloud.
using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
namespace ParallelTestingBrowserStack
{
[TestFixture]
[Parallelizable]
public class BrowserstackTest1
@nadvolod
nadvolod / gist:34c01cda52889c112d32
Last active March 10, 2016 13:27
Parallel test using sauce labs
using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
namespace SauceLabsParallelTests
{
[TestFixture("chrome", "39", "Windows 7", "", "")]
[Parallelizable]
public class SauceNUnitTest2
@nadvolod
nadvolod / gist:22622da95e405d38482ccf345eb9f479
Created April 18, 2016 00:02
Simple automated functional test that attempts to interact with an element that does not yet exist on the page
public class UnitTest1
{
private IWebDriver _driver;
[TestInitialize]
public void Setup()
{
//LocalInitialize();
BasicInitialize();
}
@nadvolod
nadvolod / ExplicitWaits.cs
Last active September 12, 2018 15:55
This is how you do an explicit wait in Selenium WebDriver
//EXAMPLE 1 - This is the most convenient method provided to us by the Webdriver API
//ExpectedConditions class provides us many different options for locating an element
var wait = new WebDriverWait(_driver,TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("elementId")));
//EXAMPLE 2 - This is a wait that dynamically checks for the presence of an element for a maximum amount of time, a bit burdensome
//because we had to write it
IWebDriver driver = new FirefoxDriver();
driver.Url = "http://somedomain/url_that_delays_loading";
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
@nadvolod
nadvolod / ImplicitWait.cs
Last active March 21, 2018 19:11
Example of a selenium webdriver implicit wait
var _driver = new FirefoxDriver();
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
//find the element that has the text Hello World
var text = _driver.FindElement(By.XPath(".//*[contains(text(),'Hello World!')]"));