This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple test to automate guessing the Heardle of the day | |
// Note: using Thread.Sleep is only used to keep things simple as part of a PoC | |
// A wait strategy should really be used but I was being lazy ;-) | |
//go to heardle of the day | |
ChromeDriver driver = new ChromeDriver(); | |
driver.Navigate().GoToUrl("https://www.heardle.app/"); | |
//find hidden field with url for the days song | |
var url = driver.FindElement(By.TagName("iframe")).GetAttribute("src"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hooks extends ScalaDsl with EN with BrowserDriver { | |
AfterStep { scenario: Scenario => | |
if (scenario.isFailed) { | |
val screenshotName = scenario.getName.replaceAll(" ", "_") | |
val screenshot = driver.asInstanceOf[TakesScreenshot].getScreenshotAs(OutputType.BYTES) | |
scenario.attach(screenshot, "image/png", screenshotName) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IWebDriver driver = new FirefoxDriver(); | |
driver.Navigate().GoToUrl("http://zzzscore.com/color2/en/"); | |
var sixtySecondsFromNow = DateTime.Now.AddSeconds(60); | |
while (DateTime.Now <= sixtySecondsFromNow) | |
{ | |
driver.FindElement(By.CssSelector(".main")).Click(); | |
} | |
Console.WriteLine($"Score: {driver.FindElement(By.Id("score"))}"); | |
driver.Quit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Automating color sense test http://zzzscore.com/color/en using webdriver and c# | |
IWebDriver driver = new FirefoxDriver(); | |
driver.Navigate().GoToUrl("http://zzzscore.com/color/en/"); | |
var sixtySecondsFromNow = DateTime.Now.AddSeconds(60); | |
while (DateTime.Now <= sixtySecondsFromNow) | |
{ | |
driver.FindElement(By.CssSelector(".main")).Click(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Automating 1 to 50 on http://zzzscore.com/1to50/en/ using webdriver and c# | |
IWebDriver driver = new FirefoxDriver(); | |
driver.Navigate().GoToUrl("http://zzzscore.com/1to50/en/?ts=1586616870389"); | |
for (var number = 1; number <= 50; number+=1) { | |
driver.FindElement(By.XPath($"//div[. = '{number}']")).Click(); | |
} | |
driver.Quit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This Gist uses the following project to provide basic visual checking functionality | |
// https://github.com/vivrichards600/AutomatedVisualTesting | |
// This Gist is quick and dirty to show how to check a web page for: | |
// Images with no alt tags, Inputs with no associated labels, Broken links and Elements with duplicate ids | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using OpenQA.Selenium.Chrome; | |
using OpenQA.Selenium.Support.Extensions; | |
using static AutomatedVisualTesting.Utilities.Compare; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let links = document.querySelectorAll('a'); | |
for(let i=0; i<links.length; i++) | |
{ | |
let random = Math.random().toString(18).substring(7); | |
links[i].innerHTML = links[i].innerHTML + random; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var inputs = document.querySelectorAll('input'); | |
var labels = document.querySelectorAll('label'); | |
for (var currentInput = 0; currentInput < inputs.length; currentInput++) { | |
var inputHasLabel = false; | |
for (var currentLabel = 0; currentLabel < labels.length; currentLabel++) { | |
if (labels[currentLabel].htmlFor == inputs[currentInput].id) { | |
inputHasLabel = true; | |
} | |
} |