In one of my projects, I need to visit one web site and click on some DOM elements to submit some forms to the web server. The web site contains one root page, one main page, and about 100 children pages. All the pages are in hierarchy structure, being the root is the top node, main page is the middle node, and children pages are the lowest level nodes.
All the DOM elements I need to click are in the children pages.
document.getElementsByClassName('class_name2').value = 1;
var forms = dom.querySelectorAll('form');
if (forms.length == 2)
function child1_submit(child_url1, class_name1, class_name2)
let xhr = new XMLHttpRequest();
xhr.open('GET', child_url1, true);
xhr.onload = function()
var parser = new DOMParser();
var dom = parser.parseFromString(xhr.responseText, 'text/html');
var button1 = dom.getElementsByClassName(class_name1);
But my code did not work, but I can see the button1 return the correct value of the DOM element.