Excel VBA - Element not found error

kyk8898

New Member
Joined
Sep 2, 2018
Messages
7
Hi there,

I tried to use the following codes to find "1+2" ( the value of inputDataSheet.Cells(2, 2)) and then change the value (default value = 10) in the input box to the value in inputDataSheet.Cells(i, 3). The code stopped at the line in bold below and said the element was not found.
May I know what's wrong with the codes? Thanks.


Code:
Sub copyodd()
'
' copyodd Macro
'
    Application.Run ("StopTimer")

    DebuggerPort = MyChrome.Manage.Capabilities("goog:chromeOptions").Item("debuggerAddress")

    MyChrome.SetCapability "debuggerAddress", "localhost:" & DebuggerPort
    

    Dim i As Integer
    Dim inputDataSheet As Worksheet
    Dim fin1 As Object
    Dim fin2 As Object
        
    Set inputDataSheet = ThisWorkbook.Sheets("InputData")
    
    For i = 2 To 276
        If inputDataSheet.Cells(i, 4) = "Yes" Then
            MyChrome.FindElementById(inputDataSheet.Cells(i, 1)).Click
            Set fin1 = MyChrome.FindElementByXPath("//div[@class='collapse-betline'][normalize-space()='" & inputDataSheet.Cells(i, 2) & "']")
           [B] Set fin2 = fin1.FindElementByXPath(".//following-sibling::div[@class='unitbet-input ']//input[@value= '10']")[/B]
            fin2.ClickDouble
            fin2.SendKeys inputDataSheet.Cells(i, 3)
            DoEvents
        End If
    Next i
    MyChrome.FindElementById("bsSendPreviewButton").Click
    
    Sheets("Sheet3").Select
    Range("A1").Select
    
End Sub


Below are the codes of the webpage extracted from developer inspection:

Code:
<div class="bet-type-col small-bet-type-col">
    <div class="collapse-content-l">
    <div class="collapse-betline">1 + 2 </div>
<div class="collapse-content-r">
    <div class="unitbet-input ">
        <span>$</span>
        <input maxlength="10" type="text" inputmode="numeric" value="10" style="font-size: 15px;">

Regards,
Kevin
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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