Run-Time Error 32 InvalidSelectorError (Reference A Cell In Selenium)

mmbhatti

New Member
Joined
Mar 5, 2023
Messages
8
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
  5. 2007
  6. 2003 or older
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hello Excel Experts ;
I am scrapping some data from webpage. Data is to fetch one by one according to the values stored in column A of osh sheet. For this, I write a selenium command of FindbyXpath in a loop. Take a look at this code please👇👇👇

For index = 2 To osh.Cells(Rows.Count, 1).End(xlUp).Row

osh.Range("D" & index).Value = cd.FindElementByXPath("//td[.=osh.Cells(index,1).Value]/parent::tr/td[8]").Text

Next index


It is generating error

Run Time Error 32.png


It means that The refer code osh.Cells(index,1).Value is not a correct way to get values from sheet column and put it an
cd.FindElementByXPath("//td[.="Formula To Refer"]/parent::tr/td[8]").Text

Can anyone guide me a correct way to write this?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try using
VBA Code:
osh.Range("D" & index).Value = cd.FindElementByXPath("//td[.=" & osh.Cells(index,1).Value & "]/parent::tr/td[8]").Text
 
Upvote 1
Solution
Try using
VBA Code:
osh.Range("D" & index).Value = cd.FindElementByXPath("//td[.=" & osh.Cells(index,1).Value & "]/parent::tr/td[8]").Text
Waoo fantastic...
Thank you so much brother..
This simple Concatenation is working perfectly.
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,290
Members
449,498
Latest member
Lee_ray

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top