'Find element using Selenium Basic for VBA

I'm trying automate data entry using Selenium Basic for Excel VBA.

I've been able to log in to the website via locating the necessary element selectors on the login page.

Afterwards I need to get to the Claims Entry Page (https://claims.curacel.co/#/pro/claims/new).
To do so after logging in, I must do a mouse move to a button (New Claim) that displays another button (Single Claim) to get to (https://claims.curacel.co/#/pro/claims/new) when clicked.

But while inspecting the first button to find a usable selector, VBA returns an error.

"ELEMENT NOT FOUND"

This is the code to log in (also I've commented a few of my attempts on finding the buttons element).

Sub Curacel()

    Dim Findby As New Selenium.By

    Set WB = New Selenium.ChromeDriver
        
    WB.Start
    WB.Get "https://claims.curacel.co/#/login"
      
    'error handling, if element property on the webpage has changed e.g name of an element or i.d
    If WB.IsElementPresent(Findby.ID("input-live")) = False Then
        MsgBox "Webpage Element(s) has been changed, kindly Alert Software Developer!", vbExclamation + vbInformation, "Contact Developer"
        WB.Quit
    End If
        
    ''input password and credentials
    ''UserName
    WB.FindElementById("input-live").SendKeys "[email protected]"
    ''Password
    WB.FindElementByXPath("/html/body/div[2]/login-component/div/div/div[1]/div[2]/form/div[2]/input").SendKeys "almadina071"
    ''loginClick
    WB.FindElementByXPath("/html/body/div[2]/login-component/div/div/div[1]/div[2]/form/div[3]/button").Click
        
    ''ATTEMPTS returning ELEMENT NOT FOUND
    'WB.FindElementById("dropdownMenuButton").Click

    'WB.FindElementByXPath("/html/body/div[2]/provider-app-component/dashboard-component/div/div[2]/div[1]/div/nav/div/ul/div/div[1]/div/button/span").Click
        
    'WB.FindElementByXPath("/html/body/div[2]/provider-app-component/dashboard-component/div/div[2]/div[1]/div/nav/div/ul/div/div[1]/div/button/text()").Click
       
    'WB.Mouse.MoveTo (WB.FindElementByCss(".dropdown"))
        
End Sub

This is the HTML code:

<button data-v-d3dab69e="" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn dropdown-toggle new-claim">
                                New Claim<span data-v-d3dab69e="" class="ml-2"><em data-v-d3dab69e="" class="fa fa-chevron-down"></em></span></button> 

                                New Claim
<span data-v-d3dab69e="" class="ml-2"><em data-v-d3dab69e="" class="fa fa-chevron-down"></em></span>
<em data-v-d3dab69e="" class="fa fa-chevron-down"></em>
<::before></::before>
<em data-v-d3dab69e="" class="fa fa-chevron-down"></em>
<span data-v-d3dab69e="" class="ml-2"><em data-v-d3dab69e="" class="fa fa-chevron-down"></em></span>
<button data-v-d3dab69e="" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn dropdown-toggle new-claim">
                                New Claim<span data-v-d3dab69e="" class="ml-2"><em data-v-d3dab69e="" class="fa fa-chevron-down"></em></span></button>


Solution 1:[1]

To do a Mouse Hover to the New Claim button that displays another button Single Claim you can use the following Locator Strategies:

Dim actions As Selenium.actions

WebElement we = driver.FindElementByXPath("//button[@id='dropdownMenuButton' and contains(., 'New Claim')]")
WB.actions.MoveToElement(we).perform
driver.FindElementByXPath("//div[@aria-labelledby='dropdownMenuButton']//a[@class='dropdown-item' and text()='Single Claim']").Click

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 undetected Selenium