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
namespace Core.BestPractices.Web.Tests.Desktop
{
// We read data from TestConfigData.PopularDesktopCombinations
[TestFixtureSource(typeof(TestConfigData), nameof(TestConfigData.PopularDesktopCombinations))]
[TestFixture]
[Parallelizable]
public class DesktopTests : WebTestsBase
{
[SetUp]
public void SetupDesktopTests()
// https://sealights.atlassian.net/wiki/spaces/SUP/pages/752648435/Using+Sealights+from+a+Jenkins+Pipeline+job
// working version
pipeline {
// agent instructs Jenkins to allocate an executor
agent any
tools {
// Install maven
maven "maven3.6"
}
// bulk of work is located here like Build, Test, and Deploy
public void loginSuccessfully() {
//something like this, needs more work
app().visit();
app().login()
assertTrue(app().isUserLoggedIn());
}
public class App(){
public void visit(){
//can visit with a page
@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 / GoodPageObject.cs
Last active May 18, 2021 15:07
Sample good page object using C#
public class ProductsPage : BasePage
{
private readonly string _pageUrlPart;
public ProductsPage(IWebDriver driver) : base(driver)
{
_pageUrlPart = "inventory.html";
}
// An element can be located using ExpectedConditions through an explicit wait
@nadvolod
nadvolod / scrollElementIntoView.cs
Last active April 5, 2021 15:52
How to scroll an element into a view using Selenium c#
element = driver.FindElement(By.LinkText("Click me using this link text!"));
//this will scroll the element and center it for interaction
var js = (IJavaScriptExecutor)Driver;
js.ExecuteScript("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center'})", element);
//this one will scroll the element into view for interactions
IJavaScriptExecutor je = (IJavaScriptExecutor)driver;
je.ExecuteScript("arguments[0].scrollIntoView(false);", element);
@nadvolod
nadvolod / azureOnSauceWithJava.yml
Created February 1, 2021 22:43
A working Azure Pipelines for Java, Selenium, SauceLabs
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
trigger:
- main
pr:
- main
pool:
public void mainTestCode(){
//put all the logic here
}
[TestMethod]
public void test1(){
mainTestCode();
}
[TestMethod]
public void test2(){
mainTestCode();
@nadvolod
nadvolod / azurePipelines.yml
Last active September 23, 2020 18:37
Working implementation of an azure pipeline that runs acceptance tests in sauce labs
pool:
name: Hosted VS2017
demands:
- msbuild
- visualstudio
- vstest
steps:
- script: set
displayName: print all variables
@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')