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 / 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 / TestOrderDependency.java
Created February 20, 2024 13:07
Test ordering problem
// Problem: Test order dependency
@FixMethodOrder(MethodSorters.NAME_ASCENDING) // This ensures the test methods are executed in lexicographical order by their names
public class TestOrderDependency {
private static WebDriver driver;
@BeforeClass
public static void setUpClass() throws Exception {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browserName", "chrome");
@nadvolod
nadvolod / .gitpod.Dockerfile
Created February 19, 2023 23:58
How to run Selenium tests in GitPod
FROM gitpod/workspace-full-vnc:latest
USER gitpod
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh && \
sdk install java 17.0.3-ms && \
sdk default java 17.0.3-ms"
# Install dependencies.
RUN sudo apt-get update \
package com.saucelabs.saucebindings.junit4.examples;
public class ConditionTester {
private boolean actionDone;
public boolean option1(boolean conditionA, boolean conditionB) {
if (!conditionA) {
actionDone = true; // Represents "Another action"
return actionDone;
}
@nadvolod
nadvolod / DefaultParameters.cs
Last active October 8, 2023 21:01
How to call a default parameter in C#
//Clafication on default parameters
public static void Sum(int aNumber, double dNum = 5.5)
{
number += aNumber;
dNumber += dNum;
}
//CLARIFICATION
@nadvolod
nadvolod / playwright-azure.yml
Last active September 25, 2023 02:54
Playwright test running in Azure DevOps
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
@nadvolod
nadvolod / DataFactory.ts
Created September 3, 2023 19:07
Using a Data Factory with Playwright and TypeScript
interface UserData {
username: string;
password: string;
}
interface AddressData {
street: string;
city: string;
zipCode: string;
}
//usage
const actualQuantity =
await locationInventoryPage.getQuantityColumnValueUsing(adjustment.receiptData.lotNumber);
const actualQuantity =
await locationInventoryPage.getInventoryQuantityUsing(adjustment.receiptData.lotNumber);
async getQuantityColumnValue(item: string): Promise<string> {
return this.getInventoryQuantityCellFromRowUsingOtherLabelSelector(item).innerText();
}
@nadvolod
nadvolod / WebDriverMethodsQuiz.java
Last active June 3, 2023 09:15
Exercises for the quiz
/**
* Go here "https://the-internet.herokuapp.com/dropdown"
* Select option 1 from the dropdown
* Assert that option 1 is selected
* Assert taht option 2 is NOT selected
* */
/*
* Go to "https://the-internet.herokuapp.com/hovers"
* Hover over the first image
@nadvolod
nadvolod / Solution1.java
Created March 19, 2023 15:54
JUnit 4 Exercise Solutions
// Solution to 1
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class AdditionTest {
@Test
public void testSum() {
int sum = 3 + 4;
int expectedSum = 7;