Sure, this kind of thing is quite common. At the end of the day though, we don’t really care where the options are being sourced from. At least not for this topic.
Sure, the following xpath should find the element you want:
Oh my gosh, you’re going to kill me. So there’s only a class=“hover” when I’m adding the bill and making the selection. Once I save the bill and view it, the selection is displayed in the field, but there is NO class=“hover”.
HTML on the VIEW page which is where I want to check the value that I have already selected:
WebElement element = driver.findElement(By.xpath("//div[@class='title' and text()='Customer Reference Attribute']/following-sibling::input"));
2020-03-16 13:44:34.235 DEBUG testcase.CRAB02 - Add Bill with CRABs - 86: element = driver.findElement(By.xpath(“//div[@class=‘title’ and text()=‘Customer Reference Attribute’]/following-sibling::input”))
2020-03-16 13:44:34.257 ERROR c.k.k.core.main.RawTestScriptExecutor - Test Cases/CRABS/CRAB02 - Add Bill with CRABs FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: driver for class: Script1584361548992
at CRAB02 - Add Bill with CRABs.run(CRAB02 - Add Bill with CRABs:189)
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.RawTestScriptExecutor.runScript(RawTestScriptExecutor.java:34)
at com.kms.katalon.core.main.RawTestScriptExecutor.doExecute(RawTestScriptExecutor.java:29)
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.runTestCaseRawScript(TestCaseMain.java:151)
at com.kms.katalon.core.main.TestCaseMain$runTestCaseRawScript$0.call(Unknown Source)
at TempTestCase1584380654016.run(TempTestCase1584380654016.groovy:295)
2020-03-16 13:44:34.269 INFO c.k.k.core.main.RawTestScriptExecutor - END Test Cases/CRABS/CRAB02 - Add Bill with CRABs
which should have given you a driver to work with. Just to clarify, this code would only work after a WebUI.openBrowser() call earlier in the script (which adds an active driver instance to the DriverFactory).