(Solved) – debugging mode and run mode behave different on selenium VBA (Excel)


I have searched for a while but cannot find a solution. also find similar link on this page and it is locked due to duplcation but actually it is not duplicate of anything. this is not Java or #c or anyother mentioned languages.
this is vba and selenium codes.
on below link on debugging mode (F8) everything working smoothly however on run mode (F5) it is not filling datefrom and dateto section or filling partily.

do you have any idea? also web site is a corporate web site so unfortunately I cannot share it.

Option Explicit
Sub Download_Report4()
Dim obj As New Selenium.WebDriver
Dim ele As WebElement
obj.Start "Chrome"
obj.Get "https://test.com"
Dim Username, Password As Range
Set Username = ActiveWorkbook.Sheets("LoginData").Range("B1")
Set Password = ActiveWorkbook.Sheets("LoginData").Range("B2")
           obj.FindElementById("UserName").SendKeys Username.Text
            obj.FindElementById("Password").SendKeys Password.Text
            Application.Wait Now   TimeValue("00:00:02")

     Dim Rows, x

For x = 2 To Sheet1.UsedRange.Rows.count Step 1

    If IsEmpty(Sheet1.Range("A" & x)) Then
        Exit For


    obj.FindElementByName("date$From").SendKeys ("01,03,2017")
       obj.FindElementByName("date$To").SendKeys (Sheet1.Range("B" & x))

End If

End Sub

by the way, date format is correct. when it is entered as 01/03/2017 chrome add dates odd. month section to date year is correct and nothing add to month section.

Leave a Reply

Your email address will not be published. Required fields are marked *