ChromeFindElements Button click not working

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

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

ChromeFindElements Button click not working

Post by drunkenmonkey » Mon Mar 29, 2021 9:20 am

Hello Dorian,
I have this tag for button on website.
<a class="btn-default add-crayon" id="btnOuvrirRensProf" data-actionurl="/fr/RenseignementProfessionnel/2205106/AfficherRenseignementsProfessionnels?ongletDepart=0" data-trigger="hover" title="Sélectionner la profession"></a>

With this instruction I can not find and apply action on the button. What am I doing wrong?
ChromeFindElements>session_id,xpath,//a[@id='btnOuvrirRensProf'],elementBtnProf
ChromeElementAction>session_id,elementBtnProf_1,click

thank you for your precious help! :D
Last edited by Dorian (MJT support) on Mon Mar 29, 2021 10:13 am, edited 1 time in total.
Reason: Code tagged as HTML, causing it to be undecipherable.

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

Re: ChromeFindElements Button click not working

Post by Dorian (MJT support) » Mon Mar 29, 2021 10:36 am

It doesn't look like you're doing anything wrong. That's exactly the same code I'd use.

If you double click the elementBtnProf array in the watch list, what do you see? What is the value of elementBtnProf_count? If it's 0, it's not finding that element, which means maybe it's in a frame? This may help you if that's the case.

If it is 1, it should be clicking it. If it's >1 then maybe you're clicking on the wrong one.

I've found that sometimes trying one of the other attributes works. Maybe see what happens if you use
title="Sélectionner la profession">

Code: Select all

ChromeFindElements>session_id,xpath,//a[@title='Sélectionner la profession'],elementBtnProf
ChromeElementAction>session_id,elementBtnProf_1,click
One thing to consider is (and I am amazed at how many people don't do this) - does the button even need to be clicked? Very often people will click through a long succession of buttons and menus when they could have quite easily just navigated to that page in the first place. I'm sure that's not the case here but it never hurts to mention it.
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 Button click not working

Post by drunkenmonkey » Mon Mar 29, 2021 3:34 pm

Thank you again Dorian for your quick answer.
I have double click the elementBtnProf array in the watch list and 0 is the result.
The button is part of a series of buttons in a panel not in a frame. Don't know if this
information can be of any help.
Thank you again! :)

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

Re: ChromeFindElements Button click not working

Post by Dorian (MJT support) » Mon Mar 29, 2021 3:49 pm

Are you able to send us the URL so we can have a look please?
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 Button click not working

Post by drunkenmonkey » Mon Mar 29, 2021 4:45 pm

No Problem Dorian,

https://dsignillustration.desjardins.co ... 5&indexe=1

click "Guest Access" button

When page Clients tab is display
Choose "Products" Tab

When page "Products" tab is display
In the "Occupation Information" panel
the 5 options button.
I was refering earlier the first one "Occupation"

Even if I was refering the french version of the site, english
have the same layout.

Thank you!

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

Re: ChromeFindElements Button click not working

Post by Dorian (MJT support) » Mon Mar 29, 2021 6:14 pm

This clicks on crayon 1.

Code: Select all

//Guest
ChromeFindElements>session_id,xpath,//a[@id='lienInvite'],el1
ChromeElementAction>session_id,el1_1,click

//Products
ChromeFindElements>session_id,xpath,//a[@id='OngletProduit'],el2
ChromeElementAction>session_id,el2_1,click

//Occupation (crayon)
ChromeFindElements>session_id,xpath,//a[@class='btn-default add-crayon'],el3
//Crayon 1
ChromeElementAction>session_id,el3_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 Button click not working

Post by drunkenmonkey » Mon Mar 29, 2021 8:01 pm

Thank you Dorian!
Guest and Products. Unfortunatly for Occupation the click event does'nt trigger
and open the window associated with the event.
For the moment the only way that seems to work on my side is with FindImagePos. :(

Thank you for your help! :D

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

Re: ChromeFindElements Button click not working

Post by drunkenmonkey » Tue Mar 30, 2021 10:38 am

Hi Dorian!
I saw this post.
viewtopic.php?f=3&t=10716&p=45601&hilit ... ate#p45601

Unfortunatly the result was ending with the 404 message.

thank you for your help! :)

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

Re: ChromeFindElements Button click not working

Post by Dorian (MJT support) » Tue Mar 30, 2021 2:47 pm

The odd thing is that clicking the crayon worked for me every single time I tried it in the editor, but not when run normally. I tried a lot of different experiments, but in the end found patience and persistence to be the key - click it, wait, click it again, wait.... this worked for me 5 times out of 5...

Code: Select all

Let>CHROMEDRIVER_EXE=c:\chromedriver.exe
let>TheURL=https://dsignillustration.desjardins.com/en/Initialisation/InitContexte?plateforme=1037400004&famille=1037441000&productCode=1037441065&indexe=1
ChromeStart>session_id
ChromeNavigate>session_id,url,%TheURL%
Wait>3
put>session_id

//Guest
ChromeFindElements>session_id,xpath,//a[@id='lienInvite'],el1
ChromeElementAction>session_id,el1_1,click

//Products
ChromeFindElements>session_id,xpath,//a[@id='OngletProduit'],el2
ChromeElementAction>session_id,el2_1,click
Wait>3

//Select Occupation
ChromeFindElements>session_id,xpath,//a[@title='Select Occupation'],el3
Wait>1
ChromeElementAction>session_id,el3_1,click
Wait>1
ChromeElementAction>session_id,el3_1,click
Wait>1
ChromeElementAction>session_id,el3_1,click
Wait>2

//Search
ChromeFindElements>session_id,xpath,//input[@class='form-control rechercheInput'],el4
ChromeSetElementValue>session_id,el4_1,Accounting clerk

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 Button click not working

Post by drunkenmonkey » Tue Mar 30, 2021 3:39 pm

It is working like a charm.
You are awesome!
Thank you so much!
Again you make my day!
:D :D :D :D :D :D :D

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

Re: ChromeFindElements Button click not working

Post by Dorian (MJT support) » Tue Mar 30, 2021 4:53 pm

A sizeable part of automation is experimentation. Partly because we're often working on something different. And sometimes something unexpected just seems to make something work. That's the first time I've tried doing it that way, and I don't even know why I tried it. I guess it's just another possible workaround to add to the mix.

I wonder if anyone else here can make it work a different way? There are a lot of great minds on this forum.

But once all is said and done, if it works, and it works every time, it must be okay.

Always happy to help.
Yes, we have a Custom Scripting Service. Message me or go here

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