A portion of my code below was able to change the attribute of a checkbox class name in a website. The code ran just fine resulting a check-mark displayed as expected but after I updated the page, that check-mark was just gone and the checkbox returned unchecked.
'Code to update checkbox class name:
Set elements = ie.document.getelementsbytagname("i")(2)
if elements.classname = "fa fa-square-o no" then
elements.classname = "fa fa-check-square yes"
end if
Below is the inspected html elements:
*Before changing class name
<div tabindex="-1" role="gridcell" aria-selected="false" aria-readonly="true" aria-required="true" class="wj-cell dt-boolean wj-align-center" style="left: 538px; top: 116px; width: 39px; height: 29px;"><i class="fa fa-square-o no"></i></div>
<i class="fa fa-square-o no"></i>
*After changing class name
<div tabindex="-1" role="gridcell" aria-selected="false" aria-readonly="true" aria-required="true" class="wj-cell dt-boolean wj-align-center" style="left: 538px; top: 116px; width: 39px; height: 29px;"><i class="fa fa-square-o no"></i></div>
<i class="fa fa-check-square yes"></i>
*After manually un-checked the box and right clicked on the box to inspect elements, this new html code popped up
<div class="axm-grid-active-editor" style="display: block; top: 225px; left: 568px; width: 38px; height: 29px;"> <div class="df__control no-border is_modified " aria-label=""><div class="df__control--boolean"><span class="modified-flag"></span> <label class="switch switch-green"><input type="checkbox" class="switch-input"> <span class="switch-label" data-on="Yes" data-off="No"></span> <span class="switch-handle"></span></label></div></div></div>
I'm still learning to use VBA to control website. Hopefully these information provides y'all enough information to give me some guidelines. If not, please let me know, I'll see if I can give out anything else.
Thanks y'all.
Aucun commentaire:
Enregistrer un commentaire