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 / LocatorDuplication.cs
Last active June 2, 2020 22:33
Code examples for Microsoft
// Ensure we have landed at the start & click the buttons
var firstNextButtonElement = AndroidManager.Wait.UntilEx(iWebDriver => (ExpectedConditions.ElementIsVisible(By.XPath("//android.widget.Button[@content-desc=\"NEXT\"]/android.view.ViewGroup")))(iWebDriver));
Assert.IsNotNull(firstNextButtonElement);
firstNextButtonElement.Click();
var secondNextButtonElement = AndroidManager.Wait.UntilEx(iWebDriver => (ExpectedConditions.ElementIsVisible(By.XPath("//android.widget.Button[@content-desc=\"NEXT\"]/android.view.ViewGroup")))(iWebDriver));
Assert.IsNotNull(secondNextButtonElement);
secondNextButtonElement.Click();
var thirdNextButtonElement = AndroidManager.Wait.UntilEx(iWebDriver => (ExpectedConditions.ElementIsVisible(By.XPath("//android.widget.Button[@content-desc=\"NEXT\"]/android.view.ViewGroup")))(iWebDriver));
@nadvolod
nadvolod / iosEmusimCapabilities.json
Last active September 3, 2020 14:32
Appium configuration to run an Emusim test on Sauce Labs
{
"appiumVersion": "1.16.0",
"platformName": "iOS",
"platformVersion": "13.2",
"deviceName": "iPhone XS Simulator",
"app": "sauce-storage:App-sim-05202020.zip"
}
@nadvolod
nadvolod / ParallelAtMethodsWithSelenium.cs
Created May 19, 2020 22:17
How to parallelize with NUnit at the method level
[TestFixture]
[Parallelizable(ParallelScope.All)]
class ParallelAtMethodsWithSelenium
{
private sealed class TestScope : IDisposable
{
public IWebDriver Driver { get; }
private string SauceUserName { get; }
private string SauceAccessKey { get; }
private Dictionary<string, object> SauceOptions { get; }
@nadvolod
nadvolod / UsingWebDriverManager.java
Last active January 17, 2023 19:47
How to use WebDriverManager with Junit 4
import io.github.bonigarcia.wdm.WebDriverManager;
//This method will run once before all of the tests in our class
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
//The setup() will run one time before every single @Test method
//In our case it will instantiate a new ChromeDriver that WebDriverManager setup for us
@Before
@nadvolod
nadvolod / ChromeDriverPath.java
Created May 16, 2020 11:37
How to set chromedriver path on windows
System.setProperty("webdriver.chrome.driver", "resources/windows/chromedriver.exe");
@nadvolod
nadvolod / JUnit5W3CChromeTest.java
Created May 8, 2020 11:39
W3C Chrome test using JUnit 5
import org.junit.jupiter.api.*;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
@nadvolod
nadvolod / CompositionTest.java
Last active April 30, 2020 15:02
A test that shows how to use composition
public class CompositionTest
{
@Test
public void aTestUsingComposition() {
InventoryPage inventoryPage = new InventoryPage(driver);
inventoryPage.open();
//If you want to interact with the header
HeaderComponent header = new HeaderComponent(driver);
header.search("backpack");
@nadvolod
nadvolod / HeaderComponent.java
Created April 30, 2020 14:54
How to decrease automation page objects using composition
public class HeaderComponent {
//All of the things related to the Header go here
//Elements related to the header section
//Methods to interact with the header
}
@nadvolod
nadvolod / KeyboardActions.java
Created April 28, 2020 15:28
This is NON working keyboard code
public class KeyboardActions()
{
//Clicks in the middle of the given element.
click(WebElement target)
//Clicks (without releasing) at the current mouse location.
clickAndHold(WebElement target)
//Performs a context-click at middle of the given element. First performs a mouseMove to the location of the element.
contextClick(WebElement target);
//Performs a double-click at middle of the given element.
doubleClick(WebElement target)
@nadvolod
nadvolod / Car.java
Created April 27, 2020 19:55
Class using composition
// A car is Composed of an enginer, wheels, and so on.
// Hence, it contains these objects inside of the class
public class Car
{
Engine engine;
Wheels wheels;
}