Question

Recorder>Capture does not work with DOMXPath

  • 26 October 2021
  • 7 replies
  • 295 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?


7 replies

Userlevel 4
Badge +7

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

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

 

Userlevel 4
Badge +7

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

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

Userlevel 4
Badge +7

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

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)

Userlevel 4
Badge +7

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

Reply