0
votes

I can change date on web page if I use internet explorer with below code(code1). however, I changed browser to chrome with selenium. (as code 2), date section on web page is changed but it is partial. for example: date is set 18/02/2020 on web page when it is opened. then I want to change date as 01/03/2017 but it is changed to 03/02/2017. that means, month section in macro shanged the date section, nothing changed on month section and year section is also changed

i have tried to change date order in macro like mm/dd/yyyy but ı cant get a proper date solution. just tried millions of code and still cannot find anything.

so please help me to change date section on chrome with using selenium. Sheet1.Range("A1") = 01/03/2017 Code1

ie.document.getElementsByName("date$From")(0).Value = Sheet1.Range("A1").Text

Code2 (selenium and VBA)

obj.FindElementById("date_From").SendKeys (sheet1.Range("A1")).Text

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">
1
same result. nothing changed. still date is wrongSelpaqM
Assuming obj is a reference to the Selenium driver, this should do it: obj.FindElementById("date_tbFrom").SendKeys(Sheet1.[a1].Text).SubmitExcel Hero
Did this update work for you>Excel Hero
@ExcelHero yes you are right obj. is webdriver. I have added submit and it gives "Server Error in '/' Application." error. by the way, when I changed date format form 01/03/2017 to 01,03,2017 date is adding normal but at that time everything works fine with debugging mode (F8) however, adding nothing to date section with F5.SelpaqM
is there anyway to directly change the value on web page. <input name="date$From" type="text" value="18/02/2020" there is an obvious value if there is a way to just replace it, it would be better.SelpaqM

1 Answers

0
votes

found a solution bymelf with try it. I used tab button usage to reach date section and used date format as 01,01,2021. used comma (,) instead of slash (/) as date seperator.

obj.FindElementByName("date$From").Clear
obj.FindElementById("place_before_date").Click
obj.SendKeys (keys.Tab)
obj.FindElementById("date$From").SendKeys (Sheet1.Range("A" & x))