I am developing a simulator to simulate user actions on a web page. In the particular case of the page that clicked on each change in the content of the page, there are several buttons. I programmatically click on each button and then want to extract the new content added to the page. If you look at:
http://www.elementbars.com/Build-a-Bar-Service.aspx#
you can find an example.
My code looks something like this:
for (var int i=0; i< buttonArray.length; i++){
Both triggerClickEvent and extractNewContent work correctly, but the problem is that after the click event is fired, the JavaScript engine has to wait a while to make sure the new content is added, but it does not behave as expected. For example, I noticed that all buttons are pressed, but extractNewContent extracts the content for the first button, which means that these two functions do not work synchronously. I used the setTimeout function, but since it does not block execution, it therefore cannot solve the problem. I also used functions that check the status of the document, but do not work.
I would be grateful if you could help me.
Thanks.
source share