readonly cells ... .. ......

Viewed 168
  1. Code is required
  2. which type of value format is needed to enter in Excel cell, with one example
  3. these are the coding stuff, also provided you an image where any can visualize how the problem look like. And in this problem we can't just use .SendKeys here it is more typical, because it have the Date-Month-Time, so help me out in this.
  4. I tried, after removing "readonly" word in HTML .. then its working fine, but this is not the way can you edit in this code,
Sub google_search()
    Dim row As Integer
    row = 2
    Dim bot As WebDriver
    Set bot = New WebDriver
    Dim GenderDD As Selenium.WebElement
    bot.Start "chrome"
    bot.Get "https://abcd.com/"

    bot.FindElementbyName("sample_cdate").SendKeys "Value"
    
    Stop

End Function

Also giving Inspect of Targeted Site, for the reference

<input type="text" class="form-control datetimepicker" name="sample_cdate" id="sample_cdate" placeholder="Date and Time of Sample Collection" **readonly**="">

enter image description here

1 Answers

I tried, after removing "readonly" word in HTML .. then its working fine, but this is not the way can you edit in this code

You should replace .SendKeys() method:

'bot.FindElementbyName("patient_id").SendKeys Sheet1.Cells(row, 3).Value
bot.ExecuteScript "arguments[0].setAttribute('value', arguments[1])", _
  Array(bot.FindElementById("sample_cdate"), _
    Format(Sheet1.Cells(row, 16).Value, "yyyy-mm-ddThh:mm:ss"))

As a readonly element, similar as on graphic WebBrowser, you cannot type input using .SendKeys(), but you can use JavaScript to set .Value attribute through programming.

As you show, your input id may be id="sample_rdate", not sample_cdate.

Related