How to capture CSS element using Selenium VBA?

Viewed 68

I am writing code in VBA using Selenium to extract information from eCommerce platforms.

I want to capture for a particular product, information like # Sizes, sizes which are available and which are stocked out.

I am able to get the # sizes and their names but not information like stock outs.

Source Code -->

<div class="size-swatch">
     <div class="circel-size variant instock">
      <span>L</span>
     </div>
</div>
<div class="size-swatch">
     <div class="circle-size variant oos">
      <span>XL</span>
     </div>
</div>

VBA Code-->

'''
Set results = driver.FindElementsByCSS("circle-size variant oos")
For Each result In results
    Worksheets("Sheet1").Cells(1, 40 + c).Value = results.Text
    c = c + 1
Next
'''
1 Answers
driver.FindElementsByCSS("circle-size variant oos")

to make this Css work, you should remove the spaces and put a .

driver.FindElementsByCSS("div.circle-size.variant oos")

should get the job done.

Related