:Santa: Advent Challenge #2 (Everyone welcome to join the event!)

You and @Vibhor.Shrivastava really inspiring the youngsters and boost their confidence to the new level. Thanks to you both guyz​:relaxed::relaxed::relaxed:

6 Likes

istockphoto-864433214-612x612

@AndersJensen, here are my solutions:

Beginner Challenge:

Regex Pattern screenshot:
image

Full Page screenshot:

Output screenshot:
image

Workflow file:
UiPath-Advent-Day2-Beginner.xaml (7.7 KB)

Advanced Challenge:

Regex Pattern screenshot:
image

Full page screenshot:

Output screenshot:
image

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:

7 Likes

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!

image
Reindeer_names.xaml (14.1 KB)

6 Likes

@Markus_Anding, Doesn’t matter you are not an expert… All that matters is trying out… and trials make you perfect :smiley:

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” :rofl:
so always looked for methods to do without regex
But slowly, i just got used to the concept of regex by trying simple :slight_smile:

Your solution is great man!! Great stuff!!

8 Likes

ADVANCED CHALLENGE
@Steven_McKeering @AndersJensen

Hi everyone, lets solve the advanced challenge for santa :slight_smile: :slight_smile: :slight_smile:

REGEX PATTERN

image

Output of the process
image

Thus at last santa clears his confusion , now he is feeling happy :heart_eyes: :heart_eyes: :heart_eyes: :heart_eyes:

Attaching workflow
AdventChallenge_2_Advanced.zip (35.6 KB)

Happy Automation

Nived N

8 Likes

Man @NIVED_NAMBIAR, this is creative! Appreciate your efforts! :slight_smile:

Well done!

5 Likes

Thank you @monsieurrahul

3 Likes

Beginner and Advanced
Hello Santa !
I really want you to come to my country - Poland, so I have to help you immediately !! :slight_smile:


First, I prepared for you the regex which you can use to find names of your reindeer :
Regex_beginner

I know that you are a little embarrassed about this situation… that’s why I have a special gift for you :gift: :slight_smile:
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 :shushing_face::wink:

There is also the result of my work directly from Studio :
Result_beginner

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 :
image

The result :
image

Save journey and see you soon in Copenhagen. HoHoHo :santa:

Beginner XAML file : Extract_Reindeer_Names.xaml (22.3 KB) :slightly_smiling_face:
Advanced XAML file : Extract_Reindeer_Name_Advanced.xaml (7.4 KB) :slightly_smiling_face:

11 Likes

Beginner & Advance Santa Challenge Advent_2 Solution!
Hooray! Extracted names of reindeer :grinning_face_with_smiling_eyes: :smiley:
Thankyou for these wonderful Challenges.

BeginnerChallengeScreenshot |690x270

Advanced ReindeerNameChallenge::

Beginner & Advance_ChallengeMain.xaml (10.2 KB)

7 Likes

Great work everyone with your replies - I am impressed with all the creative responses you made :star_struck:

@sai_s - fantastic Star Wars themed response :nerd_face:
@monsieurrahul - love it! :partying_face:
@NIVED_NAMBIAR - great work replying to both :stuck_out_tongue_winking_eye:
@Markus_Anding - fantastic work for conquering your ‘dislike’ of Regex :blush:

For anyone still wanting to complete both - less than 24 hours left! :grin:

7 Likes

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…

image image

…and on the other hand their real names.

image image

Special characters must be considered in any case, so the elf thinks too.

image

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. :gift: :gift: :gift:

7 Likes

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.

image

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.

10 Likes

Beginner Advent Challenge

Santa is trying too hard without a luck
santa-claus-thinks
Our super man is rushing for help
Po
Errrghhh Regex…
Po3 I ought to take some help here
Well Regex is so easy to build and amazingly powerful shifu
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
Result

Santa is very pleasant and takes the entire ‘Po’ team to Copenhagen
photo_verybig_4997
[Beginners Advent Challenge #2.xaml|attachment]

And heres is the XAML Beginners Advent Challenge #2.xaml (6.8 KB)

7 Likes

Santa

:santa:SANTA, We have a problem

A chubby little snowman :snowman:
had a carrot nose. :carrot:
Along came reindeers, :deer:
and what else do you suppose?

That hungry little reindeer, :deer:
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!!!

image

AdventChallenge2.zip (34.3 KB)

9 Likes

(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"))

img20201206-7

img20201206-6

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("  "," ")

img20201206-8

img20201206-3

AdventChallenge_2.zip (4.8 KB)

Santa has left for Copenhagen.

8 Likes

Ho ho hoo…Mary Christmas
:evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree: :evergreen_tree:

If you wish to watch my Santa Story the Episode #1 ==> ☃️ Advent Challenge #1 - #23 by Maneesha_de_silva
:star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck: :star_struck:

Welcome to my Santa Story Episode #2 (Beginners/Advance Advent Challenge Inside)
:point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right: :point_right:

Do you think Santa forget because of tiredness? , No way.

@Steven_McKeering was shy to say that :wink: :stuck_out_tongue_winking_eye:. let me tell you actually what happens.
:crazy_face:
After the long journey, Santa went to the bath because Our Jingle-Bell still ready with her new dress.
istockphoto-169937723-612x612
======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…….

download UnhealthyInfiniteChanticleer-small

======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]+
Biggner Output
Santa Story Biginners #2 .xaml (7.7 KB)
:loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker: :loudspeaker:
And one more thing When you run the Xaml File you will here the sound also that Santa calling for their 8 reindeers
istockphoto-597633194-612x612

====Advanced=====
1.(?<=Reindeer:\s)([A-Z][a-z][\w]+)


2. (…)(?=\ssnow)

3.
Santa Story Advanced #2 .xaml (14.4 KB)

8 Likes

Nice bro @Maneesha_de_silva

Great :clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap:t2::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap::clap:t2::clap::clap::clap::clap::clap::clap::clap::clap::clap:

3 Likes

Hehe @NIVED_NAMBIAR Tnx Bro … :blush: :innocent: :star_struck:

3 Likes

image

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.

image

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

:sunglasses: :sunglasses: :sunglasses:[^\d\W]+ :sunglasses: :sunglasses: :sunglasses:

image

Refer to the .xaml file solution for Beginner

Advent Challenge 2 - Beginner.xaml (9.1 KB)

image

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.

image

then he decided to create a 3 Step Solution to ensure that the details to be captured are Correct.

  1. Get the names of Reindeer after the Prefix "Reindeer: "
    :sunglasses: :sunglasses: :sunglasses:Reindeer:\s(?:\w+) :sunglasses: :sunglasses: :sunglasses:
  2. 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

  1. After getting the values, he decided to get only the Number from the string.
    :sunglasses: :sunglasses: :sunglasses:(\d+):sunglasses: :sunglasses: :sunglasses:

And ofcourse, to make things simple for Santa… He sent another text message like last time using Twilio.

image image
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

image

image

Refer to the zip file for the solution for Advanced

UiPath Advent Challenge2.zip (7.8 KB)

8 Likes

My solution :slight_smile:

2.xaml (14.7 KB)

Output:
image

Regex: (?<=Reindeer: )(\w+\W+\d+)(?= snow)

2 Likes