VBA Selenium XPath Click error 7

Dave_O

New Member
Joined
Dec 3, 2019
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I am using VBA Selenium to find each URL, by clicking on the next XPath.
VBA gives me a run-time error code 7
"NoSuchElementError"

Here is a sample of XPaths that I need to click:
#1 XPath
/html/body/div[1]/div/div[3]/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div/div/div[1]/div/div/div/div[1]

#2 XPath
/html/body/div[1]/div/div[3]/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div/div/div[1]/div/div/div/div[2]

#3 XPath
/html/body/div[1]/div/div[3]/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div/div/div[1]/div/div/div/div[3]


Required Outcome:
worksheet "Import" has a listing of each URL for each XPath in column D


[Sub Import()

Set WD = New ChromeDriver
URL = "https://www.bet365.com.au/#/AC/B2/C103/D20211028/E20777045/F109877762/H543/P12/"
With WD
.Start "Chrome"
.Get URL, timeout:=40000

'Can't Click No.
.FindElementByXPath("/html/body/div[1]/div/div[3]/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div/div/div[1]/div/div/div/div[1]").Click
MyString = WD.URL
Sheets("Import").Range("D" & lRow + 1) = MyString

'Next Click
'Can't Click No.
.FindElementByXPath("/html/body/div[1]/div/div[3]/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div/div/div[1]/div/div/div/div[2]").Click
MyString = WD.URL
Sheets("Import").Range("D" & lRow + 1) = MyString

'Next Click
'Can't Click No.
.FindElementByXPath("/html/body/div[1]/div/div[3]/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div/div/div[1]/div/div/div/div[3]").Click
MyString = WD.URL
Sheets("Import").Range("D" & lRow + 1) = MyString


End Sub]
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,223,990
Messages
6,175,816
Members
452,672
Latest member
missbanana

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