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
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.