Skip to main content
Question

Recorder>Capture does not work with DOMXPath

  • Oct 26, 2021 1:15 PM UTC
  • 8 replies
  • 607 views

I am trying to get the Title text using XPATH //*[@class='dati1w0a qt6c0cv9 hv4rvrfc discj3wi']/div[1]/span[1]/text() from any Facebook MarketPlace Item (eg https://www.facebook.com/marketplace/item/588418675854056 but it does not return the Title text. Pasting it into the Google Chrome Console finds the exact text correctly.

I have un-ticked all the other objects apart from DOMXPath

imageCan you help?

8 replies

Ashwin A.K
Forum|alt.badge.img
  • Navigator | Tier 3
  • Oct 26, 2021 2:04 PM UTC

Hi @Marcus Roskill​ ,

 

Could you try passing HTML InnerText into the Property Name and trying again?

This Xpath works just as well:

 

//span[@class='d2edcug0 hpfvmrgz qv66sw1b c1et5uql lr9zc1uh a8c37x1j keod5gw0 nxhoafnm aigsh9s9 qg6bub1s fe6kdd0r mau55g9w c8b282yb iv3no6db o0t2es00 f530mmz5 hnhda86s oo9gr5id']

 

Kind Regards,

Ashwin A.K


  • Author
  • Cadet | Tier 2
  • Oct 26, 2021 3:22 PM UTC

That worked! How some there is so little documentation about Capture, it is very powerful and could be used more!

 


Ashwin A.K
Forum|alt.badge.img
  • Navigator | Tier 3
  • Oct 26, 2021 4:23 PM UTC

Hi @Marcus Roskill​ ,

 

Glad I could help!

I'd appreciate it if you marked my solution as "Best" so that others facing similar issues may benefit from it as well.

Also, Naveen Automation Labs is a great resource for learning Xpaths.

 

Kind Regards,

Ashwin A.K


  • Author
  • Cadet | Tier 2
  • Oct 26, 2021 4:33 PM UTC

OK, now I'm trying to get the images using

//*[@class='beltcj47 p86d2i9g aot14ch1 kzx2olss q9uorilb pfnyh3mw ni8dbmo4 stjgntxs tv7at329 thwo4zme fv0vnmcu ggphbty4']/div/div/img[$imageCounterStr$]

where $imageCounterStr$ is in a loop, but Capture isn't writing the img URL to the variable

image


Ashwin A.K
Forum|alt.badge.img
  • Navigator | Tier 3
  • Oct 26, 2021 5:28 PM UTC

Hi @Marcus Roskill​ ,

 

Same approach, but this time type in HTML Href in place of HTML InnerText.

 

ImageDownloadUsingXpath 

To download the images, use a Browser: Download Action.

 

BrowserDownloadFileAction 

Also, if you wish to download all the images, you have to modify your Xpath like so:

 

(//*[@class='beltcj47 p86d2i9g aot14ch1 kzx2olss q9uorilb pfnyh3mw ni8dbmo4 stjgntxs tv7at329 thwo4zme fv0vnmcu ggphbty4']/div/div/img[1])[$nImageCounter$]

 

Kind Regards,

Ashwin A.K


  • Author
  • Cadet | Tier 2
  • Oct 28, 2021 12:19 PM UTC

Thank you Ashwin, that is most helpful. So how do I break out of the loop when the last image has been acquired. eg if the imageCounter reaches 7 and there are only img[6] then Capture will time-out, how do I stop at 6 (this number varies)


Ashwin A.K
Forum|alt.badge.img
  • Navigator | Tier 3
  • Oct 28, 2021 12:35 PM UTC

Hi @Marcus Roskill​ ,

 

I would suggest nesting the Actions responsible for scrapping data inside of a Loop: While Object Action.

 

Inside the Object, specify the same DOMXpath that performs the scrapping.

So essentially, you have a loop that goes on iterating as long as long as the item is present on the webpage.

 

WhileObject 

I have addressed this in an article I have penned long back, check it out if you are interested.

 

Kind Regards,

Ashwin A.K


  • Cadet | Tier 2
  • Sep 12, 2024 11:50 AM UTC

Hi,

While I am Capturing an Object in AA360 In Property Domex Path is Not Showing for me, while my Other Buddies are able to capture same thing and DomexPath is Showing the property, can Someone Help on same?