You and @Vibhor.Shrivastava really inspiring the youngsters and boost their confidence to the new level. Thanks to you both guyz:relaxed:
@AndersJensen, here are my solutions:
Beginner Challenge:
Regex Pattern screenshot:
Full Page screenshot:
Output screenshot:
Workflow file:
UiPath-Advent-Day2-Beginner.xaml (7.7 KB)
Advanced Challenge:
Regex Pattern screenshot:
Full page screenshot:
Output screenshot:
Workflow file:
UiPath-Advent-Day2-Advanced.xaml
Can’t wait to solve the next challenge! Thanks for this @Vibhor.Shrivastava, @Steven_McKeering, @AndersJensen and others!
Cheers!
By the way, here’s Santa:
Oh I really suck at RegExp, so this was a good exercise.
I see that others has more simpler expressions, but no sneek peeking…
“.*Reindeer: {1,}\s?-.(\d*){1,}”
Great fun! Take care all!
Reindeer_names.xaml (14.1 KB)
@Markus_Anding, Doesn’t matter you are not an expert… All that matters is trying out… and trials make you perfect
Just to tell you guys, once I was horrible in Regex… I was too bad on it and I really didn’t want even to try out…
When someone says regex, i was like “Oh… noooo”
so always looked for methods to do without regex
But slowly, i just got used to the concept of regex by trying simple
Your solution is great man!! Great stuff!!
ADVANCED CHALLENGE
@Steven_McKeering @AndersJensen
Hi everyone, lets solve the advanced challenge for santa
REGEX PATTERN
Output of the process
Thus at last santa clears his confusion , now he is feeling happy
Attaching workflow
AdventChallenge_2_Advanced.zip (35.6 KB)
Happy Automation
Nived N
Beginner and Advanced
Hello Santa !
I really want you to come to my country - Poland, so I have to help you immediately !!
First, I prepared for you the regex which you can use to find names of your reindeer :

I know that you are a little embarrassed about this situation… that’s why I have a special gift for you
SantaHelper !!! - chat created in DruidPlatform and reserved only for you.
You work so hard for us, so if ever a similar situation happens to you, please don’t hesitate to contact me. I secured the chat with the password Santa123. This will be our little secret


There is also the result of my work directly from Studio :
Here is my solution for Advanced
Regex pattern to extract the names of the reindeer :
Regex pattern to extract the number of snowmen :
Regex pattern to extract the names of the reindeer and the number of snowmen :
The result :
Save journey and see you soon in Copenhagen. HoHoHo
Beginner XAML file : Extract_Reindeer_Names.xaml (22.3 KB)
Advanced XAML file : Extract_Reindeer_Name_Advanced.xaml (7.4 KB)
Beginner & Advance Santa Challenge Advent_2 Solution!
Hooray! Extracted names of reindeer
Thankyou for these wonderful Challenges.
BeginnerChallengeScreenshot |690x270
Advanced ReindeerNameChallenge::
Main.xaml (10.2 KB)
Great work everyone with your replies - I am impressed with all the creative responses you made
@sai_s - fantastic Star Wars themed response
@monsieurrahul - love it!
@NIVED_NAMBIAR - great work replying to both
@Markus_Anding - fantastic work for conquering your ‘dislike’ of Regex
For anyone still wanting to complete both - less than 24 hours left!
Beginners Advent Challenge #2
After Santa the names were transparent again he discusses with his elf about the real names of the reindeers. On the one hand the names everybody knows…
…and on the other hand their real names.
Special characters must be considered in any case, so the elf thinks too.
Santa and the elf are happy now.
AdventChallenge2.Beginner.xaml (12.1 KB)
Additionally, the shower power programming elf would like to know how this approach can be implemented in PowerShell with Selenium.
#-Begin-----------------------------------------------------------------
#-Sub LoadSelenium------------------------------------------------------
Function LoadSelenium {
$Script:Path = "E:\Program Files\Selenium";
Add-Type -LiteralPath "$Script:Path\WebDriver.dll";
Add-Type -LiteralPath "$Script:Path\WebDriver.Support.dll";
}
#-WaitUntilComplete-----------------------------------------------------
Function WaitUntilComplete {
Do {
Start-Sleep -Milliseconds 250;
} Until ($Script:Driver.ExecuteScript("return document.readyState;") `
-eq "complete");
Start-Sleep -Milliseconds 625;
}
#-Sub Main--------------------------------------------------------------
Function Main() {
$Options = New-Object OpenQA.Selenium.Chrome.ChromeOptions;
$Options.BinaryLocation = `
"E:/Program Files/Google/Chrome/Application/chrome.exe";
$Script:Driver = `
New-Object OpenQA.Selenium.Chrome.ChromeDriver($Script:Path, $Options);
$baseURL = "https://regex101.com/r/AQJgbd/1";
$Script:Driver.Navigate().GoToUrl($baseURL);
WaitUntilComplete;
$TestString = `
$Script:Driver.FindElementByXPath("//span[text()='Test String']" + `
"/../following-sibling::div" + `
"//div[@role='presentation' and @class='CodeMirror-code']").Text;
$Reindeers = Select-String -InputObject $TestString -Pattern "[^\n\r0-9 -]+" `
-AllMatches | % { $_.Matches } | % { $_.Value }
Write-Host $Reindeers;
$Script:Driver.Close();
$Script:Driver.Quit();
}
#-Main------------------------------------------------------------------
LoadSelenium;
Main;
#-Error Routine---------------------------------------------------------
Trap {
If($Script:Driver.SessionId -ne $null) {
$Script:Driver.Close();
$Script:Driver.Quit();
}
Write-Host "Fehler" $_.Exception.GetType().FullName `
"in Zeile" $_.InvocationInfo.ScriptLineNumber `
`r`n $_.Exception.Message;
}
#-End-------------------------------------------------------------------
Here is the interesting part the XPath to identify the test string area. The shower power programming elf assumes that this identification is stable, because based on the term “Test String” the area is detected by its attributes.
Now the elf also wants something from Santa Claus (@loginerror), the support of the search of web elements with XPath. That would be a great gift.
Advanced Advent Challenge #2
Regular expressions, or Regex in short, are a challenging task. Santa is surprised that hardly any RPA programmer has Regex literature on his wish list. That can still change, there are still some days until Christmas.
RPA programmer, endeavor for knowledge and learn Regex, it can help you in many situations. So it also helps me to find the names of my reindeers…
…and the number of snowmen they built.
And with RPA a clearly arranged list.
Santa discusses with his shower power programming elf the best methods to handle dynamic generated web sites. They sum up again that the UI automation of dynamically generated web pages is a very demanding task. Satisfied they look at each other and wait for the next advent challenge.
AdventChallenge2.Advanced.xaml (17.1 KB)
Also here additionally the shower power programming elf would like to know how this approach can be implemented in PowerShell with Selenium.
#-Begin-----------------------------------------------------------------
#-Sub LoadSelenium------------------------------------------------------
Function LoadSelenium {
$Script:Path = "E:\Program Files\Selenium";
Add-Type -LiteralPath "$Script:Path\WebDriver.dll";
Add-Type -LiteralPath "$Script:Path\WebDriver.Support.dll";
}
#-WaitUntilComplete-----------------------------------------------------
Function WaitUntilComplete {
Do {
Start-Sleep -Milliseconds 250;
} Until ($Script:Driver.ExecuteScript("return document.readyState;") `
-eq "complete");
Start-Sleep -Milliseconds 625;
}
#-Sub Main--------------------------------------------------------------
Function Main() {
$Options = New-Object OpenQA.Selenium.Chrome.ChromeOptions;
$Options.BinaryLocation = `
"E:/Program Files/Google/Chrome/Application/chrome.exe";
$Script:Driver = `
New-Object OpenQA.Selenium.Chrome.ChromeDriver($Script:Path, $Options);
$baseURL = "https://regex101.com/r/AQJgbd/2";
$Script:Driver.Navigate().GoToUrl($baseURL);
WaitUntilComplete;
$Script:Driver.FindElementByXPath("//body").SendKeys([OpenQA.Selenium.Keys]::Tab);
$Script:Driver.FindElementByXPath("//body").SendKeys([OpenQA.Selenium.Keys]::Tab);
#$Script:Driver.FindElementByXPath("//body").SendKeys([OpenQA.Selenium.Keys]::Control + "a");
#$Script:Driver.FindElementByXPath("//body").SendKeys([OpenQA.Selenium.Keys]::Control + "c");
Add-Type -AssemblyName "System.Windows.Forms";
[System.Windows.Forms.SendKeys]::SendWait("^{a}")
Start-Sleep -Milliseconds 500;
[System.Windows.Forms.SendKeys]::SendWait("^{c}");
$TestString = Get-Clipboard;
$Reindeers = Select-String -InputObject $TestString -Pattern "(?<=Reindeer: )(\w+)" `
-AllMatches | % { $_.Matches } | % { $_.Value }
Write-Host $Reindeers;
$Script:Driver.Close();
$Script:Driver.Quit();
}
#-Main------------------------------------------------------------------
LoadSelenium;
Main;
#-Error Routine---------------------------------------------------------
Trap {
If($Script:Driver.SessionId -ne $null) {
$Script:Driver.Close();
$Script:Driver.Quit();
}
Write-Host "Fehler" $_.Exception.GetType().FullName `
"in Zeile" $_.InvocationInfo.ScriptLineNumber `
`r`n $_.Exception.Message;
}
#-End-------------------------------------------------------------------
The interesting part is here to get the complete content of the test string area. With the Selenium internal method SendKeys and the keystrokes Ctrl+A and Ctrl+C the elf becomes only the part which is available in the DOM. But with the Windows keystrokes it gets the complete content. The elf thinks it is very interesting.
#-Begin-----------------------------------------------------------------
#-Sub LoadSelenium------------------------------------------------------
Function LoadSelenium {
$Script:Path = "E:\Program Files\Selenium";
Add-Type -LiteralPath "$Script:Path\WebDriver.dll";
Add-Type -LiteralPath "$Script:Path\WebDriver.Support.dll";
}
#-WaitUntilComplete-----------------------------------------------------
Function WaitUntilComplete {
Do {
Start-Sleep -Milliseconds 250;
} Until ($Script:Driver.ExecuteScript("return document.readyState;") `
-eq "complete");
Start-Sleep -Milliseconds 625;
}
#-Sub Main--------------------------------------------------------------
Function Main() {
$Options = New-Object OpenQA.Selenium.Chrome.ChromeOptions;
$Options.BinaryLocation = `
"E:/Program Files/Google/Chrome/Application/chrome.exe";
$Script:Driver = `
New-Object OpenQA.Selenium.Chrome.ChromeDriver($Script:Path, $Options);
$baseURL = "https://regex101.com/r/AQJgbd/2";
$Script:Driver.Navigate().GoToUrl($baseURL);
WaitUntilComplete;
$Script:Driver.FindElementByXPath("//body").SendKeys([OpenQA.Selenium.Keys]::Tab);
$Script:Driver.FindElementByXPath("//body").SendKeys([OpenQA.Selenium.Keys]::Tab);
Add-Type -AssemblyName "System.Windows.Forms";
[System.Windows.Forms.SendKeys]::SendWait("^{a}")
Start-Sleep -Milliseconds 500;
[System.Windows.Forms.SendKeys]::SendWait("^{c}");
$TestString = Get-Clipboard;
$Reindeers = Select-String -InputObject $TestString -Pattern "(?<=Reindeer: )(\w+)" `
-AllMatches | % { $_.Matches } | % { $_.Value }
$Reindeers = $Reindeers.Split(" ");
$NumberOfSnowmen = Select-String -InputObject $TestString -Pattern "(\w+)(?=\s+snow)" `
-AllMatches | % { $_.Matches } | % { $_.Value }
$NumberOfSnowmen = $NumberOfSnowmen.Split(" ");
ForEach($Reindeer In $Reindeers) {
Write-Host "$($Reindeer) has made " `
"$($NumberOfSnowmen[$Reindeers.IndexOf($Reindeer)]) snowmen";
}
$Script:Driver.Close();
$Script:Driver.Quit();
}
#-Main------------------------------------------------------------------
LoadSelenium;
Main;
#-Error Routine---------------------------------------------------------
Trap {
If($Script:Driver.SessionId -ne $null) {
$Script:Driver.Close();
$Script:Driver.Quit();
}
Write-Host "Fehler" $_.Exception.GetType().FullName `
"in Zeile" $_.InvocationInfo.ScriptLineNumber `
`r`n $_.Exception.Message;
}
#-End-------------------------------------------------------------------
Both agree that XPath is an excellent basis. You drop an anchor on a descriptive element and from this position you detect the element you want to automate. Certainly the UiAutomationNext activity will work similarly, both think.
Beginner Advent Challenge
Santa is trying too hard without a luck
Our super man is rushing for help
Errrghhh Regex…
I ought to take some help here
Well Regex is so easy to build and amazingly powerful
Easiest one to find the words will be ([A-z]+) and lets try a different approach too
([^\d\W]+) The uppercase counterpart \W
(non-word-character) matches any single character that doesn’t match by \w
and we do not omit numbers too hence ^
in the beginning.
And here is the Names Santa has been looking for
Santa is very pleasant and takes the entire ‘Po’ team to Copenhagen
[Beginners Advent Challenge #2.xaml|attachment]
And heres is the XAML Beginners Advent Challenge #2.xaml (6.8 KB)
SANTA, We have a problem
A chubby little snowman
had a carrot nose.
Along came reindeers,
and what else do you suppose?
That hungry little reindeer,
looking for some lunch,
Grabbed that snowman’s nose,
Nibble, nibble, crunch!
Let’s extract these mischievous reindeers from the text.
Wow, they made quite a progress!!!
AdventChallenge2.zip (34.3 KB)
(Advanced Advent Challenge #2)
Santa seems in a hurry. I’ll provide him with short solution.
Pattern is
"(?<=Reindeer:\s)(\w+).*?(\d+)(?= snow)"
Names of the reindeer
match.Group(1).Value
Number of snowman
match.Group(2).Value
Report
String.Join(vbcrlf,results.Select(Function(m) m.Groups(1).Value+" has made "+m.Groups(2).Value+" snowmen"))
Another solution : he can directly get report from the text using the following expression.
Regex pattern is (^|snow)[\s\S]*?(Reindeer:\s*|$)
. It’s for not Match method but Replace.
report = System.Text.RegularExpressions.Regex.Replace(text,"(^|snow)[\s\S]*?(Reindeer:\s*|$)",vbcrlf).TrimStart.Replace("-"," has made").Replace(vbcrlf, "snowmen"+vbcrlf).Replace(" "," ")
AdventChallenge_2.zip (4.8 KB)
Santa has left for Copenhagen.
Ho ho hoo…Mary Christmas
If you wish to watch my Santa Story the Episode #1 ==> ☃️ Advent Challenge #1 - #23 by Maneesha_de_silva
Welcome to my Santa Story Episode #2 (Beginners/Advance Advent Challenge Inside)
Do you think Santa forget because of tiredness? , No way.
@Steven_McKeering was shy to say that
. let me tell you actually what happens.
After the long journey, Santa went to the bath because Our Jingle-Bell still ready with her new dress.
======Santa came out after bath and ready to start work========================
Santa : my lady, let’s go we have another long run
Jingle-Bell : 1 minute… please…….
======Few Hours later========================
Jingle-Bell : OK IM Ready….
Santa : ohh…. You look gorgeous……….
At the moment he saw Jingle-Bell, Santa lost his mind…
===================Both came out to start the ride,===================
Santa : oh…… my reindeers ……when I saw you that time I forget everything
Jingle-Bell : you know what last year also happen this isn’t it, that’s how you forget to send the gift for Zeus right? ( Santa Story the Episode #1)==>☃️ Advent Challenge #1 - #23 by Maneesha_de_silva
No worries thanks to me!, that why I already told you to save them in regex101.com, you made their names insn’t it.
Santa : let’s call them
Regex Pattern: [A-Z][a-z][\w]+
Santa Story Biginners #2 .xaml (7.7 KB)
And one more thing When you run the Xaml File you will here the sound also that Santa calling for their 8 reindeers
====Advanced=====
1.(?<=Reindeer:\s)([A-Z][a-z][\w]+)
2. (…)(?=\ssnow)
3.
Santa Story Advanced #2 .xaml (14.4 KB)
FINALLY, THE ROCK HAS COME BACK TO BANGKOK
I was cooking again, but Santa reached out. What to do, i still did not receive my Christmas wish.
The Rock says this: i will solve the challenge for both Beginner and Advanced for Santa.
The answer to beginner question advent 2
The rock created a solution to let the Robot open the Browser and check for the names of the reindeer directly from the site. Upon capturing the details, the robot closed the browser, then identified the names accordingly using regular expressions
[^\d\W]+
Refer to the .xaml file solution for Beginner
Advent Challenge 2 - Beginner.xaml (9.1 KB)
But the rock is not finished yet, he still wants to finish the solution with the most electrifying move of all time. Hence, he is answering also the Advanced challenge.
Instead of getting the robot to open the browser, this time, the Rock just put the details in a notepad for the robot to read.
then he decided to create a 3 Step Solution to ensure that the details to be captured are Correct.
- Get the names of Reindeer after the Prefix "Reindeer: "
Reindeer:\s(?:\w+)
- After getting the names of the Reindeer, get the number of Snowmen by passing the names of the Reindeer (You can never be too sure)
item.tostring = Reindeer: (Output of First Regex)
strRegexForSnowMan = (?:(?:\s-\s)(\d+))\s*snow
Hence, he created a variable to pass the item.ToString+strRegexForSnowMan
- After getting the values, he decided to get only the Number from the string.
(\d+)
And ofcourse, to make things simple for Santa… He sent another text message like last time using Twilio.
ofcourse, he did not forget to put it also on the output pane for Santa Steve & Jingle-Bell Jensen (@Steven_McKeering and @AndersJensen to be happy
Refer to the zip file for the solution for Advanced
UiPath Advent Challenge2.zip (7.8 KB)