I want to select an option to one of my select field. The field is different from other select fields because it reloads the entire page when I select a value. Please help!!
Unable to select option by value 'MyValue' of object 'My TestObject' using regular expression (Root cause: org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
Here is another workaround solution for your case, please give it another try. It will CLICK on the select object and select âMyValueâ option by sending that value as keys
I tried the above code & the option is getting selected & saved.
However, after completing the
WebUiCommonHelper.selectOrDeselectOptionsByValue(new Select(webElement), 'MyValue', true, true, to, 'using regular expression log') step execution it logs the below error & never makes it to the wait step WebUI.waitForPageLoad(30)
Error Logged:-
Test Cases/Main Test Cases/SampleTests FAILED because (of) org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
In this case, itâs probably you have to write select steps to handle this special case. Unfortunately I donât have any sample site to test, so hopefully this script will work for you:
import com.kms.katalon.core.testobject.TestObject as TestObject import com.kms.katalon.core.webui.common.WebUiCommonHelper import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
Please donât care about âWarningâ type, itâs just showing you warnings for current step behaviors. So after that step, the item you want is selected correctly on the browser or not?
Okay⌠It still doesnât save the value I selected & I still see the same problem. Due to modifications in the Failure handling, error got logged as Warning. But behavior is the same.
Yeah. Still the same issue. Here is the log, see if this helpsâŚ
Object 'My Test Object' is clickable
End action : waitForElementClickable
Start action : selectOptionByValue
Finding web element with id: 'My Test Object' located by 'By.xpath: XPATH' in '30' second(s)
Found 1 web elements with id: 'My Test Object' located by 'By.xpath: XPATH' in '30' second(s)
Selecting options on object 'My Test Object' with value 'My Value' using regular expression
Selecting options on object 'My Test Object' with value 'My Value' using regular expression
Option at index '18' with value 'My Value' is selected using regular expression
Unable to select option by value 'My Value' of object 'My Test Object' using regular expression (Root cause: org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
Yes, I did add the wait step before selecting, but it did not work. Also I tried to send Tab keys after. But of no luck.
I can see in the browser that it finds the object & the value, but it doesnât get saved because the page reloads as soon as we have a value in there.
How about adding âWait For Element Visibleâ or âWait For Element Presentâ before selecting that option? This message âelement is not attached to the page documentâ is due to unavailability of an element being accessed by findelement method.
Even a simple drop-down selection is susceptible to cause this issue (mismatched DOM probably often due to some overzealously page-rewriting JavaScript triggered by input / on change).
Wondering if instead of various workarounds (mostly WebUI.selectOptionByIndex(findTestObject(âPage_Active User/select_Entryâ), Entry, FailureHandling.CONTINUE_ON_FAILURE) for me - not documented for selectOptionByValue BTW, and never feeling good about overrides, of which OPTIONAL also would be one)âŚ
I have started learning the Katalon Studio - but got stuck almost immediately with âSelect Option By ValueââŚ
Here is the actual code:
WebUI.waitForElementVisible(findTestObject(âBRONTO_ALL/select_Select a Sub-Account52â), 10)
WebUI.selectOptionByValue(findTestObject(âBRONTO_ALL/select_Select a Sub-Account52â), âFinancial Media Corp (finmc)â, true)
Here is the error i get:
Test Cases/BrontoSendMsg FAILED because (of) Unable to select option by value âFinancial Media Corp (finmc)â of object âObject Repository/BRONTO_ALL/select_Select a Sub-Account52â using regular expression (Root cause: No option matched.)
If this is a different - please let me know and will post in the correct section.
Note: The same works fine with Katalon RecorderâŚ