Hi all,
I am having a problem with selecting an item in a dropdown list.
My case is a bit special that the dropdown list is in the span tag, not the select tag which makes my Select function not working. All comments and suggestions are greatly appreciated. Thank you all beforehand.
The website I am testing: https://www.ourbetterworld.org/gsoty/2018
The HTML:
My function code:
WebDriver driver = DriverFactory.getWebDriver();
WebElement element = driver.findElement(By.xpath(xpath));
Select selectElement = new Select(element);
selectElement.selectByVisibleText(value);
Thread.sleep(5000);
My error:
2019-08-11 17:01:22.478 DEBUG testcase.Stories_SelectGoodStory - 7: actionKeyword.SelectByXPathKeyword.selectDropdownByXpath(“//select[@id=“edit-field-gsoty-category-target-id”]”, “Animals”)
2019-08-11 17:01:22.627 ERROR com.kms.katalon.core.util.KeywordUtil - Fail to click on element
2019-08-11 17:01:22.628 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - com.kms.katalon.core.exception.StepFailedException: Fail to click on element
2019-08-11 17:01:22.643 ERROR c.k.katalon.core.main.TestCaseExecutor - Test Cases/Feature_TestCase/TestCase_Stories/Stories_SelectGoodStory FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Fail to click on element
at com.kms.katalon.core.util.KeywordUtil.markFailed(KeywordUtil.java:19)
at com.kms.katalon.core.util.KeywordUtil$markFailed$0.call(Unknown Source)
at actionKeyword.SelectByXPathKeyword.selectDropdownByXpath(SelectByXPathKeyword.groovy:191)
at actionKeyword.SelectByXPathKeyword.invokeMethod(SelectByXPathKeyword.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at Stories_SelectGoodStory.run(Stories_SelectGoodStory:29)
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 TempTestCase1565517660941.run(TempTestCase1565517660941.groovy:21)