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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,374
Messages
6,171,720
Members
452,418
Latest member
kennettz

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