I tested this keyword with a Test Case that I made at Stale element not found, is this relate to using same Object? - #113 by kazurayam with a bit of ammendments:
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable
import com.kazurayam.ks.ToggleSmartWait
/**
* automate signing-in to Microsoft Azure DevOps with Smart Wait
*/
TestObject makeTestObject(String id, String xpathExpression) {
TestObject tObj = new TestObject(id)
tObj.addProperty("xpath", ConditionType.EQUALS, xpathExpression)
return tObj
}
// enable Smart Wait explicitly
ToggleSmartWait.toggleON()
String url = "https://dev.azure.com/${GlobalVariable.ACCOUNT}"
WebUI.openBrowser(url)
WebUI.setViewPortSize(800, 800)
TestObject loginfmt = makeTestObject("loginfmt", "//input[@name='loginfmt']")
WebUI.sendKeys(loginfmt, GlobalVariable.EMAIL)
TestObject nextButton = makeTestObject("Next", "//input[@id='idSIButton9']")
WebUI.click(nextButton)
TestObject passwd = makeTestObject("Passwd", "//input[@name='passwd']")
WebUI.sendKeys(passwd, GlobalVariable.PASSWD)
TestObject signinButton = makeTestObject("SignIn", "//input[@id='idSIButton9']")
WebUI.click(signinButton)
TestObject yesButton = makeTestObject("Yes", "//input[@id='idSIButton9']")
WebUI.click(yesButton)
WebUI.closeBrowser()
ToggleSmartWait.toggleOFF()
This test case automates going throuh the Login procedure into Microsoft Azure DevOps, which is deeply AJAX driven so that definitely requires the SmartWait enabled. If I don’t have SmartWait enabled, the test case will fail raising an exception of “Stale Element reference”.
Intentionally I chose "Project > Settings > Execution > Web UI > Default Smart Wait” to be “Disabled” and ran this test case. It worked fine for me.
This proved that the com.kazurayam.ks.ToggleSmartWait class can toggle on and off the Smart Wait even if the "Project > Settings > Execution > Web UI > Default Smart Wait” is set “Disabled”. This is what I wanted to see.
Now I am glad that I could find this workaround. I would be able to help those who got confused by Smart Wait. I would expect a lot more in future.