I'm very new to Javascript. I try to set a javascript code in Selenium IDE with "execute Script" command in order to open a settings button that share the same class="MyClass" (there are 16 buttons).
After clicking the button appears a window with some options. When these options are visible I want to click the option that can be located by Xpath, and finally I want to save the settings for each button, then repeat the same for the 16 buttons.
The code I have so far it seems to work partially, because locates the 16 button and I can do the for loop and click on them, but it seems that runs so fast and this generates that the other actions don't be completed.
var items = document.getElementsByClassName("MyClass");
for (var i = 0; i < items.length; i++) {
items[i].click(); // To open each button that have the class = "MyClass"
document.evaluate(" //li[contains(.,'sometext')] ", document.body, null, 9, null). singleNodeValue.click(); // Click on elemenet by Xpath
document.getElementById("savesettings").click(); // Save settings
};
How can I add some pause for example like this?
var items = document.getElementsByClassName("MyClass");
for (var i = 0; i < items.length; i++) {
items[i].click(); // To open each button that have the class = "MyClass"
**Command to wait 2 seconds**
document.evaluate(" //li[contains(.,'sometext')] ", document.body, null, 9, null). singleNodeValue.click(); // Click on elemenet by Xpath
**Command to wait 2 seconds**
document.getElementById("savesettings").click();
};
Thanks in advance for any help.