ChromeFindElements & ChromeElementAction

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

ChromeFindElements & ChromeElementAction

Post by drunkenmonkey » Tue Feb 23, 2021 1:16 pm

Hi!
I tried to get work the 2 commands for clicking a button but was not able to. When inspecting the object I have this code. Someone can help me figure out how to use the 2 commands working. Thank you!

Code: Select all

<a id="sommaire-boutton" class="btn btn-primary btn-actualiser pull-right" tabindex="0" data-actionurl="/fr/Sommaire/2130043/ActualiserPrimes"><span></span>Actualiser</a>

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: ChromeFindElements & ChromeElementAction

Post by Dorian (MJT support) » Tue Feb 23, 2021 2:35 pm

Code: Select all

ChromeFindElements>session_id,xpath,//a[@id='sommaire-boutton'],element
ChromeElementAction>session_id,element_1,click
<a id="sommaire-boutton" class="btn btn-primary btn-actualiser pull-right" tabindex="0" data-actionurl="/fr/Sommaire/2130043/ActualiserPrimes"><span></span>Actualiser</a>

Let's make it easier to see :

<a id="sommaire-boutton" class="btn btn-primary btn-actualiser pull-right" tabindex="0" data-actionurl="/fr/Sommaire/2130043/ActualiserPrimes"><span></span>Actualiser</a>

ChromeFindElements>session_id,xpath,//a[@id='sommaire-boutton'],element

ChromeElementAction>session_id,element_1,click
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: ChromeFindElements & ChromeElementAction

Post by drunkenmonkey » Tue Feb 23, 2021 3:58 pm

Thank you so much for your help. Just made my day. :D :D :D

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: ChromeFindElements & ChromeElementAction

Post by drunkenmonkey » Tue Feb 23, 2021 5:09 pm

If I may ask another question. I have an item list on the web site and I want to select the secon item = PE20">Vie entière payable 20 ans - Patrimoine bonifié.
How do I manage do let it work? Thank you!
<div class="row">
<div class="col-sm-24 col-md-8 col-lg-8">
<div class="form-group">

<label for="FamilleSelectionnee">Catégorie de protection</label><select class="selectionFamille form-control" data-persistable="protection" id="FamilleSelectionnee" name="FamilleSelectionnee"><option selected="selected" value="1">Vie permanente</option>
</select>
</div>
</div>
<div class="col-sm-24 col-md-11 col-lg-11">
<div class="form-group">

<label for="ProduitSelectionne">Protection</label><select class="form-control" data-persistable="protection" id="ProduitSelectionne" name="ProduitSelectionne"><option selected="selected" value="PE10">Vie entière payable 10 ans - Patrimoine bonifié</option>
<option value="PF10">Vie entière payable 10 ans - Croissance accélérée</option>
<option value="PE20">Vie entière payable 20 ans - Patrimoine bonifié</option>
<option value="PF20">Vie entière payable 20 ans - Croissance accélérée</option>
<option value="PE00">Vie entière payable à 100 ans - Patrimoine bonifié</option>
<option value="PF00">Vie entière payable à 100 ans - Croissance accélérée</option>
</select>
</div>
</div>
</div>
With this code it does'nt work
ChromeFindElements>session_id,xpath,//a[@id='ProduitSelectionne'],element
ChromeSetElementValue>session_id,elements_1,PE10">Vie entière payable 10 ans - Patrimoine bonifié
ChromeElementAction>session_id,element_1,click

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: ChromeFindElements & ChromeElementAction

Post by Dorian (MJT support) » Tue Feb 23, 2021 6:46 pm

Once you've mastered these Chrome commands they're very powerful. Look very closely and you'll see it's the same usage every time. It will take a while, but eventually you'll get that eureka moment :D

Code: Select all

<select class="form-control" data-persistable="protection" id="ProduitSelectionne" name="ProduitSelectionne"><option selected="selected" value="PE10">Vie entière payable 10 ans - Patrimoine bonifié</option>
<option value="PF10">Vie entière payable 10 ans - Croissance accélérée</option>
<option value="PE20">Vie entière payable 20 ans - Patrimoine bonifié</option>
<option value="PF20">Vie entière payable 20 ans - Croissance accélérée</option>
<option value="PE00">Vie entière payable à 100 ans - Patrimoine bonifié</option>
<option value="PF00">Vie entière payable à 100 ans - Croissance accélérée</option>
</select>

Code: Select all

ChromeFindElements>session_id,xpath,//select[@class='form-control'],element
ChromeSetElementValue>session_id,element_1,Vie entière payable 20 ans - Patrimoine bonifié
To make it easier to see :

Code: Select all

<AAAAAAA BBBBBBB="CCCCCCC" data-persistable="protection" id="ProduitSelectionne" name="ProduitSelectionne"><option selected="selected" value="PE10">Vie entière payable 10 ans - Patrimoine bonifié</option>
<option value="PF10">Vie entière payable 10 ans - Croissance accélérée</option>
<option value="PE20">Vie entière payable 20 ans - Patrimoine bonifié</option>
<option value="PF20">DDDDDDD</option>
<option value="PE00">Vie entière payable à 100 ans - Patrimoine bonifié</option>
<option value="PF00">Vie entière payable à 100 ans - Croissance accélérée</option>
</select>

Code: Select all

ChromeFindElements>session_id,xpath,//AAAAAAA[@BBBBBBB='CCCCCCC'],element
ChromeSetElementValue>session_id,element_1,DDDDDDD
Here's a generic snippet worth saving. Once you understand what XX is (read and digest this article - it will pay massive dividends later) we can find the element using ChromeFindElements. Then we can do one of three things with it. Get the data/value, Set the Value, or perform an action (click, submit, or clear).

Code: Select all

ChromeFindElements>session_id,xpath,//XX[@XX='XX'],el
//Get the data
ChromeGetElementData>session_id,el_1,text,increment_id
//Set the value to "Canada"
ChromeSetElementValue>session_id,el_1,Canada
//Do something
ChromeElementAction>session_id,el_1,click
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: ChromeFindElements & ChromeElementAction

Post by drunkenmonkey » Tue Feb 23, 2021 6:58 pm

Thank you again many times. I'll look applied this lesson. :D :D :D

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts