How to get value from css selector

On the First picture you can see that the xpath have function for its value so i try to get in on CSS selector to view the value of the function. Now i want to get the value given by the CSS selector to validate it. But as you can see the getText show me the error(“Unable to find the element located”).

Can anyone help me? I want to get the value of the CSS selector as String Value to Validate it.



Hey @ifuentes, you can check this doc here to get the CSS value.

Hello @chen.lee I try to used the getCSSValue but still the same.
Is that because of the function of the CSS?

I also try the just the xpath only not the CSS selector but still the same


Uploading: Screen Shot 2022-07-25 at 3.05.17 PM.png…

Can you show your full code and the full error log?

I also try to change the element from ‘id’ to ‘async-rules’ but still can get it.

@chen.lee
```2022-07-25 15:03:49.316 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.cssSelector: document.querySelector(#input-390).value’. Please recheck the objects properties to make sure the desired element is located.
2022-07-25 15:03:49.579 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Cannot get CSS ‘async-rules’ value on ‘Object Repository/Facilities/General Information/lblGeneralCSS’. (Root cause: com.kms.katalon.core.exception.StepFailedException: Cannot get CSS ‘async-rules’ value on ‘Object Repository/Facilities/General Information/lblGeneralCSS’.
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.getCSSValueKeyword.getCSSValue(GetCSSValueKeyword.groovy:84)
at com.kms.katalon.core.webui.keyword.builtin.getCSSValueKeyword.execute(GetCSSValueKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.getCSSValue(WebUiBuiltInKeywords.groovy:4594)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$getCSSValue$8.call(Unknown Source)
at ainescripts.Facilities.VerifyGeneralInformation(Facilities.groovy:507)
at cucumber.runtime.Utils$1.call(Utils.java:26)
at cucumber.runtime.Timeout.timeout(Timeout.java:16)
at cucumber.runtime.Utils.invoke(Utils.java:20)
at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:48)
at cucumber.runtime.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:50)
at cucumber.runner.TestStep.executeStep(TestStep.java:68)
at cucumber.runner.TestStep.run(TestStep.java:50)
at cucumber.runner.PickleStepTestStep.run(PickleStepTestStep.java:53)
at cucumber.runner.TestCase.run(TestCase.java:47)
at cucumber.runner.Runner.runPickle(Runner.java:44)
at cucumber.runtime.Runtime.runFeature(Runtime.java:120)
at cucumber.runtime.Runtime.run(Runtime.java:106)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main$run.call(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFile_closure1.doCall(CucumberBuiltinKeywords.groovy:108)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFile_closure1.doCall(CucumberBuiltinKeywords.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:74)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordMain$runKeyword.call(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:75)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile$0.callStatic(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:248)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile.call(Unknown Source)
at WSVerification1658732567772.run(WSVerification1658732567772:2)
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.WSVerificationExecutor.runScript(WSVerificationExecutor.java:180)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:174)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:157)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:149)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:131)
at com.kms.katalon.core.main.TestCaseMain.runFeatureFile(TestCaseMain.java:172)
at com.kms.katalon.core.main.TestCaseMain$runFeatureFile$0.call(Unknown Source)
at TempTempCase1658732565168.run(TempTempCase1658732565168.groovy:25)

Your CSS selector is in an incorrect format. You are using JS, not the CSS selector format. Follow this post to learn how to use CSS selectors here.

@chen.lee yeah i forgot it javascript. Many thanks i did it like this

1 Like