skip to Main Content

enter image description here

I am using this xpath

//*[@class="relative mr3"]//div[2]//img/alt/text()

to extract

"Tramontina Primaware 18 Piece Non-stick Cookware Set, Steel Gray" 

however I am getting empty excel cell.

2

Answers


  1. I’m having some difficulty reading your code because of a poor colour scheme, but my suspicion is that you’ve fallen into the common trap of thinking that "//div[2]" means "the second descendant div" whereas it actually means "every descendant div that is the second div child of its parent".

    Login or Signup to reply.
  2. The value of a attribute alt is not found with img/alt/text() but just with img/@alt

    Try this XPath:

    //*[@class="relative mr3"]/div[2]/img/@alt
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search