excel - VBA document.all.item only works on username but not password -


first, here's code: (the code no different standard codes vba-open-website if save time reading, placed <---------here indicate put password)

sub login_2wiki()  dim ieapp internetexplorer  dim iedoc object  dim ietable object  dim clip dataobject  dim iusr object  dim ipwd object  dim iform object  'create new instance of ie  set ieapp = new internetexplorer  'you don’t need this, it’s debugging  ieapp.visible = true  'assume we’re not logged in , go directly login page  ieapp.navigate "https://xxx.xxxxx.com/login.action?"  while ieapp.busy: doevents: loop  until ieapp.readystate = readystate_complete: doevents: loop  set iedoc = ieapp  'fill in login form – view source browser control names  iedoc  set iform = .document.getelementbyid("login-container")  set iusr = iform.document.getelementbyid("os_username")  iusr.value = "guest"  set ipwd = iform.document.getelementbyid("os_password")  ipwd.value = "abc"   .document.getelementsbyname("loginbutton")(0).click  end  while ieapp.busy: doevents: loop  until ieapp.readystate = readystate_complete: doevents: loop   'close 'er  ieapp.quit  set ieapp = nothing  end sub   

and here's part of source code on webpage (it atlassian confluence page if matters):

<div class="field-group "     > <label id="os_username-label" for="os_username"> username     </label>              <input type="text" name="os_username" id="os_username" class="text   " placeholder="username" data-focus="0"     />                   </div>                          <div class="field-group"> <label id="os_password-label" for="os_password"> password     </label> <input type="password" name="os_password" id="os_password"  class="password " placeholder="password"  />               </div>                         

problem: code filled username not password on webpage. gives no errors. notice there data-focus = "0" in source view of webpage, , wonder if that's thing causing problem.

edit: i've replace .document.all.item .document.getelementbyid method, althought code can find element os_password (no errors), fails assign value it. os_username working before.

try:

with .document.getelementbyid("os_password")     .focus()     .value = "abc" end 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -