Unable to click the a href

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mnaeem
Junior Coder
Posts: 30
Joined: Wed Mar 10, 2021 5:05 pm

Unable to click the a href

Post by mnaeem » Fri Oct 14, 2022 7:28 pm

Hello,
Please see the uploaded picture at onedrive link below. I want to click the No, thanks! hyper link but I am unable to achieve it. Appreciate some help.
Image

This is the code I am trying to execute.

Code: Select all

ChromeFindElements>session_id,xpath,//*[contains(text(),'No, thanks!' )]//parent::a,elements
ChromeElementAction>session_id,elements_1,click

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Unable to click the a href

Post by hagchr » Sat Oct 15, 2022 8:09 am

Hi, I think it gets confused by the "," in your xpath. You can try

Code: Select all

Let>tmp0=//*[contains(text(),'No, thanks!')]//parent::a
ChromeFindElements>session_id,xpath,tmp0,elements
ChromeElementAction>session_id,elements_1,click

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

Re: Unable to click the a href

Post by Dorian (MJT support) » Sat Oct 15, 2022 10:32 am

hagchr wrote:
Sat Oct 15, 2022 8:09 am
Hi, I think it gets confused by the "," in your xpath. You can try

Code: Select all

Let>tmp0=//*[contains(text(),'No, thanks!')]//parent::a
ChromeFindElements>session_id,xpath,tmp0,elements
ChromeElementAction>session_id,elements_1,click
Yep, commas can mess things up a little.

Taking your example :

Code: Select all

ChromeFindElements>session_id,xpath,//*[contains(text()%comma%'No%comma% thanks!')]//parent::a,elements
ChromeElementAction>session_id,elements_1,click
Or we could also use Partial Link Text or Link Text :

Code: Select all

ChromeFindElements>session_id,partial link text,No%comma% tha,elements
ChromeElementAction>session_id,elements_1,click

Code: Select all

ChromeFindElements>session_id,link text,No%comma% thanks!,elements
ChromeElementAction>session_id,elements_1,click
Yes, we have a Custom Scripting Service. Message me or go here

mnaeem
Junior Coder
Posts: 30
Joined: Wed Mar 10, 2021 5:05 pm

Re: Unable to click the a href

Post by mnaeem » Sun Oct 16, 2022 6:45 pm

Thanks it worked

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