Bonjour à tous,

Je débute en langage Selenium pour VBA (désolé par avance) et je ne parviens à valider mon script en cliquant sur cette zone href une fois la recherche effectuée sur un site internet :

Nom : Capture d’écran 2023-02-17 141914.jpg
Affichages : 109
Taille : 123,3 Ko

Il s'agit du bouton qui permet de valider la recherche effectuée par le script sur le site internet.

Voici mon code complet :

Sub Plan_de_cadastre_n°1()

Dim Chrome As New WebDriver
Dim SearchTerm As String
Dim file_name As String

SearchTerm1 = Range("F3").Value 'Ville
SearchTerm2 = Range("E3").Value 'Code Postal
SearchTerm3 = Range("B24").Value 'Préfixe
SearchTerm4 = Range("B25").Value 'Section
SearchTerm5 = Range("B26").Value 'Numéro

If ActiveSheet.Shapes("Plan de cadastre n°1").ControlFormat.Value = 1 Then

' Ouvre Chrome
Chrome.Start "Chrome", "https://www.cadastre.gouv.fr"
Chrome.Get "/"

' On attend 1 seconde
Chrome.Wait 1000

'Faire une recherche par références cadastrales
Chrome.FindElementByLinkText("Préférer une recherche par références cadastrales").Click

' On attend 1 seconde
Chrome.Wait 1000

'Lancer la recherche
Chrome.FindElementById("ville").SendKeys SearchTerm1

Chrome.FindElementById("codePostal").SendKeys SearchTerm2

Chrome.FindElementById("prefixeParcelle").SendKeys SearchTerm3

Chrome.FindElementById("section").SendKeys SearchTerm4

Chrome.FindElementById("numeroParcelle").SendKeys SearchTerm5

Chrome.FindElementById("numeroParcelle").SendKeys Chrome.Keys.Enter

' On attend 1 seconde
Chrome.Wait 1000

End If

End Sub


Le XPath de la zone en question est //*[@id="onglet"]/table/tbody/tr[2]/td[1]/a

Evidemment, les lignes suivantes ne fonctionnent pas :

Chrome.FindElementsByXPath("//*[@id='onglet']/table/tbody/tr[2]/td[1]/a").Click
Chrome.FindElementsByXPath("//*[@id='onglet']/table/tbody/tr[2]/td[1]/a").SendKeys Chrome.Keys.Enter

Auriez-vous une idée ?

Je vous remercie par avance pour votre aide.

Marswalk