How to fix StaleElementReferenceException: stale element reference: element is not attached to the page document

Hello everyone!

I am trying to select an option by the label in a selector but when I run the test it selects it and loads the page of a form that I need to fill out but it does not continue with the test throwing the following ERROR.

=============== ROOT CAUSE =====================
Caused by: org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
At object: ‘Object Repository/Page_Curso 01_CURSO_PRUE_20220311_0958/select_Agregar una actividad’

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html

03-11-2022 11:40:55 AM selectOptionByLabel(findTestObject(“Page_Curso 01_CURSO_PRUE_20220311_0958/select_Agregar una actividad”), “Reunión de Zoom”, true)

Elapsed time: 10.214s

Unable to select option by label ‘Reunión de Zoom’ of object ‘Object Repository/Page_Curso 01_CURSO_PRUE_20220311_0958/select_Agregar una actividad’ using regular expression (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to select option by label ‘Reunión de Zoom’ of object ‘Object Repository/Page_Curso 01_CURSO_PRUE_20220311_0958/select_Agregar una actividad’ using regular expression
at

My code is:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

WebUI.openBrowser(‘https://pru-gnp-lms.biaani.com/login/index.php’)

WebUI.maximizeWindow(FailureHandling.STOP_ON_FAILURE)

WebUI.setText(findTestObject(‘Object Repository/Page_GNP - IDEAS Iniciar sesin en el sitio/input_Nombre de usuario_username’),
‘miguelangel.marin@gnp.com.mx’)

WebUI.setText(findTestObject(‘Object Repository/Page_GNP - IDEAS Iniciar sesin en el sitio/input_Contrasea_password’), ‘$Oow201a’)

WebUI.click(findTestObject(‘Object Repository/Page_GNP - IDEAS Iniciar sesin en el sitio/button_Acceder’))

WebUI.click(findTestObject(‘Object Repository/Page_rea personal/a_Miscellaneous’))

WebUI.click(findTestObject(‘Object Repository/Page_GNP Todos los cursos/button_Crear un nuevo curso’))

WebUI.setText(findTestObject(‘Object Repository/Page_GNP Crear un nuevo curso/input_Nombre completo del curso_fullname’),
‘01_CURSO_PRUE_20220311_1139’)

WebUI.setText(findTestObject(‘Object Repository/Page_GNP Crear un nuevo curso/input_Nombre corto del curso_shortname’),
‘01CP111139’)

WebUI.click(findTestObject(‘Object Repository/Page_GNP Crear un nuevo curso/input_Administrar marcas estndar_saveanddisplay’))

WebUI.click(findTestObject(‘Page_01CP110958 Participantes/a_Miscellaneous - 01CP110958’))

WebUI.click(findTestObject(‘Object Repository/Page_Curso 01_CURSO_PRUE_20220311_0958/a_Consulta Cifras_action-menu-toggle-0’))

WebUI.click(findTestObject(‘Object Repository/Page_Curso 01_CURSO_PRUE_20220311_0958/a_Activar edicin’))

WebUI.selectOptionByLabel(findTestObject(‘Page_Curso 01_CURSO_PRUE_20220311_0958/select_Agregar una actividad’), ‘Reunión de Zoom’,
true)

WebUI.waitForPageLoad(10)

WebUI.setText(findTestObject(‘Object Repository/Page_Editando Reunin de Zoom/div_1 1’), ‘1

1

’)

WebUI.setText(findTestObject(‘Object Repository/Page_Editando Reunin de Zoom/input_Tema_name’), ‘Sesión 1’)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Page_Editando Reunin de Zoom/select_00 01 02 03 _f6e37b’),
‘13’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Page_Editando Reunin de Zoom/select_00 01 02 03 _f6e37b_1’),
‘0’, true)

WebUI.click(findTestObject(‘Object Repository/Page_Editando Reunin de Zoom/input_Solo VoIP_option_audio’))

WebUI.click(findTestObject(‘Object Repository/Page_Editando Reunin de Zoom/input_Al finalizar la actividad_submitbutton2’))

WebUI.click(findTestObject(‘Object Repository/Page_Curso 01_CURSO_PRUE_20220311_0958/a_Consulta Cifras_action-menu-toggle-0’))

WebUI.click(findTestObject(‘Object Repository/Page_Curso 01_CURSO_PRUE_20220311_0958/a_Personalizacin’))

WebUI.click(findTestObject(‘Object Repository/Page_Personalizacin del Curso/a_Tipo de curso’))

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Page_Personalizacin del Curso/select_Seleccione . Presencial _9b502a’),
‘WebEx’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Page_Personalizacin del Curso/select_Seleccione . Zoom’),
‘1’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Page_Personalizacin del Curso/select_0 1 2 _81e00f’),
‘1’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Page_Personalizacin del Curso/select_0 1 2 _81e00f_1’),
‘1’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Page_Personalizacin del Curso/select_0 1 2 _81e00f_1_2’),
‘2’, true)

WebUI.click(findTestObject(‘Object Repository/Page_Personalizacin del Curso/a_Permitir para Coordinadores’))

WebUI.click(findTestObject(‘Object Repository/Page_Personalizacin del Curso/input_Ingrese aqu las direcciones a mostrar_53c629’))

WebUI.closeBrowser()

When you paste code within this forum, you should put 3 backticks above and below your code, like ```. The backtick is found on the same key as the tilde ~.

This may not fix your “staleElement” error, but you have the boolean set to true, but you do not have any Regular Expression within your selection. Set the boolean to false unless you need RegEx. That way, you can be in control of the select comparison and not get any unexpected surprises.

WebUI.selectOptionByValue(findTestObject('Object Repository/Page_Personalizacin del Curso/select_0 1 2 _81e00f_1'), '1', false)

Also, for your “staleElement”, perhaps you can try:

WebUI.selectOptionByValue(findTestObject('Object Repository/Page_Personalizacin del Curso/select_Seleccione . Zoom'), '1', false)

WebUI.waitForElementClickable(findTestObject('Object Repository/Page_Personalizacin del Curso/select_0 1 2 _81e00f'), 10)
WebUI.selectOptionByValue(findTestObject('Object Repository/Page_Personalizacin del Curso/select_0 1 2 _81e00f'), '1', false)

Please use the Code Formatting syntax to make your code better readable for others.