0

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 "almadinacliniczaria@gmail.com"
    ''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>
Community
  • 1
  • 1
Israel
  • 21
  • 5
  • Can you check if it's in any iframes or shadowroots? – Arundeep Chohan Jan 01 '22 at 02:54
  • Thank you, i completely omitted the possibility of the element could within a shadowRoot... however i went ahead to study some solutions proffered using SeleniumBasic for vba handling ShadowRoot elements, ( https://www.wiseowl.co.uk/vba-macros/videos/vba-scrape-websites/elements-shadow-dom/ ) this precisely, so i inspected the element, and hoped to see a shadowRoot above that hosts it but there was none. kindly login to the website if you could and inspect perhaps it's there and i'm missing it. Thank You – Israel Jan 01 '22 at 09:20

1 Answers1

0

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
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352