Skip to content

Instantly share code, notes, and snippets.

View andreidbr's full-sized avatar

Andrei Dobra andreidbr

View GitHub Profile
@andreidbr
andreidbr / _resume.scss
Created May 14, 2017 07:14
Customized section of _resume.scss
.icon-link-item {
display: inline-block;
margin-left: 5px;
> a {
color: #c7c7c7;
}
> a:hover {
color: #333;
}
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@andreidbr
andreidbr / pom.xml
Last active September 5, 2017 11:39
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.andreidbr</groupId>
<artifactId>SeleniumMavenTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SeleniumMavenTest</name>
@andreidbr
andreidbr / SeleniumMavenDemo.java
Created September 4, 2017 17:41
Official Selenium test case
package demo;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
public class SeleniumMavenDemo {
@andreidbr
andreidbr / pom.xml
Created March 13, 2018 18:56
An example pom.xml file with Selenium and TestNG as dependencies
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
@andreidbr
andreidbr / Utils.java
Created March 13, 2018 19:06
An Utils class that instantiates a Webdriver object
package PortfolioTests.Utilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public final class Utils {
public static WebDriver driver;
@andreidbr
andreidbr / Portfolio.java
Created March 13, 2018 19:36
A Java class with basic Selenium tests organized with TestNG
package PortfolioTests;
import PortfolioTests.Utilities.Utils;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@andreidbr
andreidbr / cssVariableDemo01.java
Created March 15, 2018 18:43
A Selenium Webdriver test that compares CSS classes
@Test(testName = "Click 'A' Test", description = "Check that you can click the 'A' key and the correct response triggers", groups = {"01Drums"})
public void aKeyTest() {
driver.findElement(By.xpath("/html/body/div[2]/div[1]")).click();
WebElement aKey = driver.findElement(By.xpath("/html/body/div/div[1]"));
Actions builder = new Actions(driver);
Action sendAKey = builder.moveToElement(aKey).sendKeys("A").build();
sendAKey.perform();
Assert.assertEquals(aKey.getAttribute("class"), "key playing");
}
@andreidbr
andreidbr / cssVariableDemo02.java
Created March 15, 2018 18:56
A Selenium test to compare two CSS styles of an element
@Test(testName = "02 Clock Functionality Test", description = "Check that the 02 Clock page functions correctly", groups = {"02Clock"})
public void verifyClockTest() throws InterruptedException {
driver.findElement(By.xpath("/html/body/div[2]/div[2]")).click();
String firstStyle = driver.findElement(By.xpath("/html/body/div/div/div[3]")).getAttribute("style");
Thread.sleep(2000);
String secondStyle = driver.findElement(By.xpath("/html/body/div/div/div[3]")).getAttribute("style");
Assert.assertNotEquals(firstStyle, secondStyle, "There are no differences in the two styles");
}
@Test(testName = "03 CSS Variable Functionality Test", description = "Check that the 03 CSS Variable page functions correctly", groups = {"03CSS"})
public void verifyCSSTest() {
driver.findElement(By.xpath("/html/body/div[2]/div[3]")).click();
String initialStyle = driver.findElement(By.xpath("/html")).getAttribute("style");
WebElement slider = driver.findElement(By.xpath("/html/body/div/p[1]/input[2]"));
slider.click();
slider.sendKeys(Keys.ARROW_RIGHT);
String secondStyle = driver.findElement(By.xpath("/html")).getAttribute("style");
Assert.assertNotEquals(initialStyle, secondStyle);