in my system I have to add elements. After I do this, I need to validate them. The things is tthat there is a group of element that are validated in a different way. To solve that I do the next thing:
WebUI.callTestCase(findTestCase('9-Validacion 2'), [:], FailureHandling.STOP_ON_FAILURE)
WebUI.delay(3)
String ExpectedValue = 'BACTE'
WebDriver driver;
driver = DriverFactory.getWebDriver()
//WebElement Table = driver.findElement(By.xpath('//div/div/div/div/div/div/div/div[3]/div/div'))
WebElement Table = driver.findElement(By.id('Grid1ContainerTbl'))
//Grid1ContainerTbl
List<WebElement> Rows = Table.findElements(By.tagName('tr'))
println(Rows.size())
//List<WebElement> tr_withImg = Table.findElements(By.xpath('//tr[*//img[contains(@id, \'vMODIFICAR_\')]]'))
//List<WebElement> Cols = tr_withImg.get(tr_withImg.size() - 1).findElements(By.tagName('td'))
for (int i = 0; i < Rows.size(); i++) {
List<WebElement> Cols = Rows.get(i).findElements(By.tagName('td'))
for (int j = 0; j < Cols.size(); j++) {
if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
println(Cols.get(j).getText())
WebUI.delay(3)
WebUI.callTestCase(findTestCase('9-ValidacionMicroBiologia 3'), [:], FailureHandling.STOP_ON_FAILURE)
}else{
WebUI.delay(3)
WebUI.callTestCase(findTestCase('9-ValidacionNormal 3'), [:], FailureHandling.STOP_ON_FAILURE)
}
}
}
The problem with this is that each TC I call works correctly but whenever one of them finishes, I encounter this error:
2019-09-16 10:47:22.947 DEBUG testcase.ValidacionAux - 1: if (getText().equalsIgnoreCase(ExpectedValue))
2019-09-16 10:47:22.989 ERROR c.k.katalon.core.main.TestCaseExecutor - Test Cases/ValidacionAux FAILED.
Reason:
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=76.0.3809.132)
For documentation on this error, please visit: Exceptions | Selenium
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘CONSOLIDADORAPT’, ip: ‘192.168.10.81’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 76.0.3809.132, chrome: {chromedriverVersion: 76.0.3809.68 (420c9498db8ce…, userDataDir: C:\Users\guill\AppData\Loca…}, goog:chromeOptions: {debuggerAddress: localhost:57930}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 83b412a18adedcab0a290d93b7a7c958
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:20)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at org.openqa.selenium.remote.RemoteWebElement.getText(RemoteWebElement.java:166)
at org.openqa.selenium.WebElement$getText$0.call(Unknown Source)
at ValidacionAux.run(ValidacionAux:42)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1568641402345.run(TempTestCase1568641402345.groovy:21)
2019-09-16 10:47:22.991 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/ValidacionAux
I had this problem before but when I had to interact with a button or other elements. I tried using delays or implementing other solutions but nothing works. Any suggestions?