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 / Fluent Wait in Selenium Webdriver
Created May 2, 2016 23:20
How to create a fluent wait for IWebDriver
var _driver = new FirefoxDriver();
var wait = new DefaultWait<IWebDriver>(_driver)
{
Timeout = TimeSpan.FromSeconds(10),
Message = "Dude, where's my element?",
PollingInterval = TimeSpan.FromSeconds(1)
};
wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
var myElement = wait.Until(ElementIsVisible(elementId));
@nadvolod
nadvolod / WebDriverWait class
Created May 3, 2016 22:43
WebDriverWait class definition
namespace OpenQA.Selenium.Support.UI
{
//
// Summary:
// Provides the ability to wait for an arbitrary condition during test execution.
public class WebDriverWait : DefaultWait<IWebDriver>
{
public WebDriverWait(IWebDriver driver, TimeSpan timeout);
public WebDriverWait(IClock clock, IWebDriver driver, TimeSpan timeout, TimeSpan sleepInterval);
}
@nadvolod
nadvolod / Complicated app
Created May 15, 2016 02:09
How to handle a complicated with application with frames and dynamic elements
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
using System;
using NUnit.Framework;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
using System.IO;
namespace DragDropTutorial
{
@nadvolod
nadvolod / Browser.cs
Created June 24, 2016 01:10
Browser class for the LightPomFramework
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Threading;
using System.IO;
using System.Reflection;
namespace Framework
{
public enum Drivers
@nadvolod
nadvolod / SeleniumIframe.cs
Last active September 7, 2021 02:33
How to work with Selenium Webdriver iFrames
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
namespace SeleniumWebdriverTips
{
[TestClass]
@nadvolod
nadvolod / ChromeExtensionRemoteWebdriver.cs
Last active March 6, 2024 16:24
Add a Chrome extension to RemoteWebDriver using Selenium and C#
private IWebDriver GetRemoteDriver()
{
//1. Getting the path to my extension
var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
ChromeOptions options = new ChromeOptions();
options.AddExtension(outPutDirectory + @"\3.1.3_0.crx");
//2. Adding the appropriate capabilities
//---- >>>> Don't do this - Setting the browser name is redundant
//options.AddAdditionalCapability(CapabilityType.BrowserName, "chrome", true);
@nadvolod
nadvolod / powershellWebRequest
Created November 30, 2016 17:20
Posh web request sample
Invoke-WebRequest -URI http://www.bing.com?q=how+many+feet+in+a+mile
@nadvolod
nadvolod / WriteToFIlePosh
Created November 30, 2016 17:22
Powershell write to file example
Add-Content c:\scripts\test.txt "The End"
@nadvolod
nadvolod / VBScript to write to file
Created November 30, 2016 17:25
write to file VBS
Set objFSO=CreateObject("Scripting.FileSystemObject")
' How to write file
outFile="c:\test\autorun.inf"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "test string" & vbCrLf
objFile.Close