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
public void mainTestCode(){
//put all the logic here
}
[TestMethod]
public void test1(){
mainTestCode();
}
[TestMethod]
public void test2(){
mainTestCode();
@nadvolod
nadvolod / cypress.spec.js
Created September 11, 2020 15:39
Sample Cypress tests
context('Login page', ()=>{
beforeEach(()=> {
cy.visit('https://www.saucedemo.com/')
})
it('can open page', () => {
cy.title().should('eq', 'Swag Labs')
})
it('can login', () => {
cy.get('#user-name').type('standard_user')
@nadvolod
nadvolod / OptimizedRadioButtonTest.java
Created September 8, 2020 17:22
An optimized radio button clicking test
@Test
public void optimizedTest() throws AssertionError {
driver.navigate().to("https://www.techlistic.com/p/selenium-practice-form.html");
var male = driver.findElement(By.id("sex-0"));
var actions = new Actions(driver);
actions.moveToElement(male).click().perform();
assertTrue(male.isSelected());
var female = driver.findElement(By.id("sex-1"));
@nadvolod
nadvolod / BadGherkin.feature
Last active August 31, 2020 17:26
Bad Gherkin example
Given driver webUrl + "/demo"
And input("#abr02tre", Key.CONTROL + "a")
And match temp contains "565d"
And match temp contains "5d"
When input("#rc02ert", "test")
Then text("divId45")
var assert = require('assert');
let failureCount = 0;
before(function () {
console.log('before()', failureCount)
});
beforeEach(function () {
console.log('beforeEach()', failureCount)
});
@Before
public void setUp() throws MalformedURLException {
logger.debug("Started setUp();");
logger.debug("platformVersion=>" + platformVersion + ". deviceName=>" + deviceName);
MutableCapabilities capabilities = new MutableCapabilities();
capabilities.setCapability("appiumVersion", "1.16.0");
capabilities.setCapability("autoAcceptAlerts", "true");
capabilities.setCapability("idleTimeout", "90");
capabilities.setCapability("noReset", "true");
@nadvolod
nadvolod / AndroidCapabilities.cs
Created July 15, 2020 19:25
Setting up Android capabilities for a real device test in Sauce Labs
var capabilities = new AppiumOptions();
//We can run on any version of the platform as long as it's the correct device
//Make sure to pick an Android or iOS device based on your app
capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Google Pixel 4");
capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
//make sure you set locale as sometimes it opens in a different location and throws off locations
capabilities.AddAdditionalCapability("locale", "en");
capabilities.AddAdditionalCapability("language", "en");
//The next major version of Appium (2.x) will **require** this capability
capabilities.AddAdditionalCapability("automationName", "UiAutomator2");
import com.saucelabs.saucebindings;
SauceOptions sauceOptions = new SauceOptions();
//Set a build name
sauceOptions.setBuild("Sample Build Name");
new SauceSession(sauceOptions).start();
@nadvolod
nadvolod / POM.xml
Created June 14, 2020 22:39
How to fix maven compiler errors
<build>
<pluginManagement>
<plugins>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
@nadvolod
nadvolod / SauceTestWatcher.java
Created June 3, 2020 15:58
How to add test status using Sauce Labs with JUnit 4
package com.hilton.v2;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
public class SauceTestWatcher extends TestWatcher {
private WebDriver driver;