Skip to content

Instantly share code, notes, and snippets.

Last active June 19, 2022 10:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vivrichards600/8a42aed3ca7ab7c4f2219952de067f3e to your computer and use it in GitHub Desktop.
A quick and dirty test to guess the Headle.App of the day
// 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();
//find hidden field with url for the days song
var url = driver.FindElement(By.TagName("iframe")).GetAttribute("src");
//get song title out of the soundcloud url
url = url.Replace("", "");
var title = url.Substring(0, url.IndexOf("&")).Split("/")[1].Replace("-"," ");
//only take first 10 characters (some titles are weird) e.g. some titles have a -1 in them
// also check if the title is actually longer than 10 characters. If it is, shorten the title
var shortenedTitle = title.Replace(" 1","");
if (shortenedTitle.Length > 10) shortenedTitle = title.Substring(0, 10);
//click to start the game
//play todays headle - this let you submit an answer
//provide song title for autocomplete
//select song from list
//submit answer
//check we see the text which says we got the days heardle!
var winner = driver.FindElement(By.XPath("/html/body/main/div[2]/div/div[2]/p[2]")).Text;
Assert.IsTrue(winner.Equals("You got today's Heardle within 1 second."));
//play a bit of the headle before we do a little victory dance and quit :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment