I need to press programmatically on button1, after pressing select list will appear and then on this select list i need to click on button2.
id of button1 is #mx899, but on the web page i'm working on, you cannot use command for clicking, like document.querySelector('#mx899').click();, it does not work. You can call function sendEvent('click', 'mx899', ''); for clicking on button1, for clicking button2 you can call function sendEvent('click', 'mx3481[R:2]', '');
How to call these commands sequentially and alternately with one script?
How to correctly expect the appearance of 'Select list'?
sendEvent('click', 'mx899', '');
sendEvent('click', 'mx3481[R:2]', 'ev');
I tried to use Promise + async/await, but second click does not work, I think my code lacks a check for waiting to appear 'Select list'
async function b()
{
function f1()
{
return new Promise(resolve =>
{
resolve(sendEvent('click', 'mx899', ''));
})
}
function f2()
{
return new Promise(resolve =>
{
resolve(sendEvent('click', 'mx3481[R:2]', ''));
})
}
async function myf()
{
let res1 = await f1();
let res2 = await f2();
return [res1,res2];
}
return myf();
}
b();
Since I dont have the code of the html form and I dont know why querySelector or getElementById are not availiable to you, I can only provide an approach and not a running solution. Buy you might adjust it towards your environment.
function performActions() {
let element1 = document.getElementById('mx899'); // get the button element
element1.click(); // send the click event to the button
let handle = window.setInterval(function() { // create a timer...
let element2 = document.getElementById('mx3481[R:2]'); // try to get the list element
if (!element2) return; // When the list element is not found, return and try on next timer iteration
element2.click(); // list element is found, send click event
window.clearInterval(handle); // stop the timer
}, 500); // ...that triggers every 500ms
}
This code is NOT tested since I dont have the HTML code of the form!