Skip to content

Instantly share code, notes, and snippets.

View batmi02's full-sized avatar

Michael Battat batmi02

  • Applitools
View GitHub Profile
@batmi02
batmi02 / gist:5c19718a0c05b27d6f4412343c0dab02
Created May 23, 2019 17:01
Abel's code for calling Applitools
#region Applitools Actions
public T TakeVisualPicture<T>(string tag)
{
_eyes.CheckWindow(tag);
return (T) Convert.ChangeType(this, typeof(T));
}
#endregion
@batmi02
batmi02 / BasePage.cs
Created May 23, 2019 17:05
Abel's code for initiating Applitools Eyes
// initialize the eyes SDK and set your private API key
var eyes = new Eyes();
eyes.ApiKey = appliToolsKey;
eyes.Batch = batchInfo;
// Start the test by setting AUT's name, window or the page name that's being tested,
//viewport width and height
TESTNAME = testName;
eyes.Open(driver, "Mercury Health Web App", TESTNAME, WINDOWSIZE);
@batmi02
batmi02 / MercuryAppTestsExcerpt.cs
Created May 23, 2019 17:57
Excerpt from MercuryHealthAppTests.cs
[TestMethod]
[TestCategory("UITests")]
public void Add1stDonutTest()
{
var webApp = HomePage.Launch(_applitoolsApiKey,
_applitoolsBatchName,
_applitoolsBatchId,
"Add 1st Donut Test",
_browserType);
// <reference types="cypress" />
describe('todo actions', () => {
beforeEach(() => {
cy.visit('http://todomvc-app-for-testing.surge.sh/')
cy.get('.new-todo', {timeout: 6000}).type('Clean room{enter}')
})
it('should add a new todo to the list', () => {
it(‘should add a new todo to the list’, () => {
cy.visit(‘http://todomvc-app-for-testing.surge-sh/’)
cy.get(‘.new-todo’, {timeout: 6000}.type(“Clean room{enter}”)
cy.get(‘label’).should(‘have.text’, ‘Clean room’)
cy.get(‘.toggle’).should(‘not.be.checked’)
})
//Start the test capture
eyes.open(driver, “Demo App”, “Login Page Test”, new RectangleSize(800,800));
//Take a screenshot so AI can analyze
eyes.checkWindow(“Login Window);
//End the test
eyes.closeAsync();
@Before
public void beforeEach() {
//Open the app
driver.get("http://localhost:8000/tablesort.html");
//Click on the Rank column
driver.findElement(By.id("rank")).click();
}
@Test
@UseDataProvider("testForDataFailure")
public void testLoginFailure(String username, String password, String expected, String testName, string locatorId) {
//try loggin in with username and password
login(username,password);
//get the text from the alert element
String actual = driver.findElement(By.id("alert")).getText();
assertEquals(testName, expected, actual);
}
@BeforeClass
public static void setBatch() {
// Must be before ALL tests (at Class Level)
batch = new BatchInfo("Data Driven Testing");
// Initialize the Runner for your test
runner - new ClassicRunner();
//Initialize the eyes SDK
eyes = new Eyes(runner);
@Before
public void beforeEach() {
}
@Test
public void chartTest1() {
eyes.open(driver, "Demo App", "ChartTest 1", new RectangleSize(1200,800));
driver.get("http://localhost:8000/BarChart.html");
eyes.checkWindow("1st Test Window");