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
obj.FindElementById(LoginButton").Click
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
Else
obj.FindElementByName("date$From").Clear
obj.FindElementByName("date$To").Clear
obj.FindElementByName("date$From").SendKeys ("01,03,2017")
obj.FindElementByName("date$To").Click
obj.FindElementByName("date$To").SendKeys (Sheet1.Range("B" & x))
obj.FindElementById("btnSearch").Click
obj.FindElementById("btndownload").Click
End If
Next
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.
I will giving little bit more details. on below code for internet explorer is working very well unless after download button click, ie 11 prompt "do you want to open or save" question stops my macro and loops ending. this is the reason why I move the macro selenium.
Public Sub Download_Report()
Dim ie As New InternetExplorer
Dim myElem As Variant
ie.Visible = True
ie.navigate "https://test.com"
ie.document.getElementById("UserName").Focus
ie.document.getElementById("LUserName").Value = Sheets("LoginData").Range("B1").Text
ie.document.getElementById("Password").Focus
ie.document.getElementById("Password").Value = Sheets("LoginData").Range("B2").Text
ie.document.getElementById("LoginButton").Click
End If
Dim Rows, x
For x = 2 To Sheet1.UsedRange.Rows.count Step 1
If IsEmpty(Sheet1.Range("A" & x)) Then
Exit For
Else
While .Busy Or .readyState < 4: DoEvents: Wend
ie.document.getElementsByName("date$From")(0).Value = Sheet1.Range("A" & x).Text
While .Busy Or .readyState < 4: DoEvents: Wend
ie.document.getElementsByName("date$To")(0).Value = Sheet1.Range("B" & x).Text
While .Busy Or .readyState < 4: DoEvents: Wend
ie.document.getElementById("btnSearch").Click
While .Busy Or .readyState < 4: DoEvents: Wend
ie.document.getElementById("btndownload").Click
End If
Next
End With
End Sub
date can be use as picker after clicked but also can be filled as text also, date section code on web site as is below. also date to section is as same as . Website code (website is behind a firewall)
<input name="date$From" type="text" value="18/02/2020" size="6" id="date_tbFrom" class="searchSelect">
<input type="hidden" name="date_From_Client" id="date_From_Client">
obj.wait(2000)
after each section to being sure about time. after complete 2 days ı am still on the same point – SelpaqMobj.wait(500)
Dim obj As New Selenium.WebDriver
– SelpaqM