Unable to click Object despite verifyElementClickable returning true

Hi,
I’m trying to WebUI.click Object("//a/em"), but ElementNotInteractableException occurs.

Situation:

  1. verifyElementClickable returns true.
  2. Spy Web can “Verify and Highlight” it.
  3. the day before yesterday WebUI.click it was a success.
  4. other Objects(button, li etc.) is clickable.
  5. waitElementClickable(Object, 30) , but unable to click it.

Please tell me how to click the Object.

Version: 7.8.0

ErrorMessage:

2020-11-30 10:36:39.814 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2020-11-30 10:36:39.824 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/webTest/common/call
2020-11-30 10:36:41.338 DEBUG testcase.call                            - 1: openBrowser(URL)
2020-11-30 10:36:41.755 INFO  c.k.k.core.webui.driver.DriverFactory    - Starting 'Chrome' driver
11 30, 2020 10:36:41 午前 org.openqa.selenium.remote.DesiredCapabilities chrome
情報: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
2020-11-30 10:36:41.777 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['args', '[--start-maximized]']
2020-11-30 10:36:41.807 INFO  c.k.k.core.webui.driver.DriverFactory    - Action delay is set to 0 milliseconds
Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 39662
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
11 30, 2020 10:36:45 午前 org.openqa.selenium.remote.ProtocolHandshake createSession
情報: Detected dialect: W3C
2020-11-30 10:36:45.658 INFO  c.k.k.core.webui.driver.DriverFactory    - sessionId = e821184a2ce5c3e0e167d8d587db4aee
2020-11-30 10:36:45.685 INFO  c.k.k.core.webui.driver.DriverFactory    - browser = Chrome 86.0.4240.198
2020-11-30 10:36:45.685 INFO  c.k.k.core.webui.driver.DriverFactory    - platform = Windows 10
2020-11-30 10:36:45.686 INFO  c.k.k.core.webui.driver.DriverFactory    - seleniumVersion = 3.141.59
2020-11-30 10:36:45.687 INFO  c.k.k.core.webui.driver.DriverFactory    - proxyInformation = ProxyInformation { proxyOption=NO_PROXY, proxyServerType=HTTP, username=, password=********, proxyServerAddress=, proxyServerPort=0, executionList="", isApplyToDesiredCapabilities=true }
[FINE] No subscribers registered for event class com.kms.katalon.core.event.TestingEvent
[FINE] No subscribers registered for event class org.greenrobot.eventbus.NoSubscriberEvent
2020-11-30 10:36:46.917 DEBUG testcase.call                            - 2: setText()
2020-11-30 10:36:47.737 DEBUG testcase.call                            - 3: setEncryptedText()
2020-11-30 10:36:48.010 DEBUG testcase.call                            - 4: submit()
2020-11-30 10:36:48.124 DEBUG testcase.call                            - 5: println(verifyElementClickable(findTestObject("Object Repository/webTest/menu/header/provider/em_provider")))
true
2020-11-30 10:36:50.904 DEBUG testcase.call                            - 6: waitForElementClickable(findTestObject("Object Repository/webTest/menu/header/provider/em_provider"), 30)
2020-11-30 10:36:51.112 DEBUG testcase.call                            - 7: click(findTestObject("Object Repository/webTest/menu/header/provider/em_provider"))
2020-11-30 10:36:51.327 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Unable to click on object 'Object Repository/webTest/menu/header/provider/em_provider' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object 'Object Repository/webTest/menu/header/provider/em_provider'
	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.ClickKeyword.click(ClickKeyword.groovy:76)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:617)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$5.call(Unknown Source)
	at call.run(call:21)
	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:393)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:384)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:363)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:355)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
	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 TempTestCase1606700197148.run(TempTestCase1606700197148.groovy:25)
Caused by: org.openqa.selenium.ElementNotInteractableException: element not interactable
  (Session info: chrome=86.0.4240.198)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'LAPTOP-GTLVUU3D', ip: '192.168.1.69', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 86.0.4240.198, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\S_MATS~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:56110}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: e821184a2ce5c3e0e167d8d587db4aee
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:19)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
	at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.lambda$new$0(EventFiringWebDriver.java:404)
	at com.sun.proxy.$Proxy14.click(Unknown Source)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:417)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:69)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.call(ClickKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:76)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:617)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$5.call(Unknown Source)
	at Script1606556337622.run(Script1606556337622.groovy:21)
	... 11 more
)
2020-11-30 10:36:51.334 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/webTest/common/call FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to click on object 'Object Repository/webTest/menu/header/provider/em_provider' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object 'Object Repository/webTest/menu/header/provider/em_provider'
	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.ClickKeyword.click(ClickKeyword.groovy:76)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:617)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$5.call(Unknown Source)
	at call.run(call:21)
	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:393)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:384)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:363)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:355)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
	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 TempTestCase1606700197148.run(TempTestCase1606700197148.groovy:25)
Caused by: org.openqa.selenium.ElementNotInteractableException: element not interactable
  (Session info: chrome=86.0.4240.198)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'LAPTOP-GTLVUU3D', ip: '192.168.1.69', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 86.0.4240.198, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\S_MATS~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:56110}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: e821184a2ce5c3e0e167d8d587db4aee
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:19)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
	at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.lambda$new$0(EventFiringWebDriver.java:404)
	at com.sun.proxy.$Proxy14.click(Unknown Source)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:417)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:69)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.call(ClickKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:76)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:617)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$5.call(Unknown Source)
	at Script1606556337622.run(Script1606556337622.groovy:21)
	... 11 more
)
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:39)
	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.ClickKeyword.click(ClickKeyword.groovy:76)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:617)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$5.call(Unknown Source)
	at call.run(call:21)
	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:393)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:384)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:363)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:355)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
	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 TempTestCase1606700197148.run(TempTestCase1606700197148.groovy:25)
Caused by: com.kms.katalon.core.exception.StepFailedException: Unable to click on object 'Object Repository/webTest/menu/header/provider/em_provider'
	... 19 more
Caused by: org.openqa.selenium.ElementNotInteractableException: element not interactable
  (Session info: chrome=86.0.4240.198)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'LAPTOP-GTLVUU3D', ip: '192.168.1.69', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 86.0.4240.198, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\S_MATS~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:56110}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: e821184a2ce5c3e0e167d8d587db4aee
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:19)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
	at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.lambda$new$0(EventFiringWebDriver.java:404)
	at com.sun.proxy.$Proxy14.click(Unknown Source)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:417)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:69)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.call(ClickKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	... 17 more

2020-11-30 10:36:55.093 INFO  .k.c.e.TestExecutionSocketServerEndpoint - MHTML is available at /C:/Users/S_MATS~1/AppData/Local/Temp/Katalon/Test Cases/webTest/common/call/20201130_103637/Test-Cases_webTest_common_call.mhtml
2020-11-30 10:36:56.364 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/webTest/common/call

By Changing XPath, clickable now.
But I don’t know why can’t click em tag Object that I used to be able to do.

@shunmatsu_begginer

You can try to use Chrome Dev Tool and check if the old XPath (which use the tag) locates the desired element.

1 Like

Even if WebUI.verifyElementClickable(TestObject tObject) returned true, it does not mean the HTML element is actually clickable. Are you surprised? I will tell you …

You can read the source of WebUI.verifyElementClickable keyword at

at Line#78 you can find

                    WebElement foundElement = WebUIAbstractKeyword.findWebElement(to, RunConfiguration.getTimeOut())
                    if (foundElement.isEnabled()) {
                        ...
                        return true

This means, WebUI.verifyElementClickable() will return true whenever foundElement.isEnabled() returns true. The variable foundElement is an instance of org.openqa.selenium.webdriver.WebElement. The javadoc of WebElement is here:

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/WebElement.html#isEnabled()

boolean isEnabled()
Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
See W3C WebDriver specification for more details.

Let me repeat it:

This will generally return true for everything but disabled <input> elements

So any <em> element will always be found clickable by WebUI.verifyElementClickable() because <em> is not <input disabled>.


@ThanhTo

I suppose, this keyword verifyElementClickable() is wrongly named, useless, and tends to be misunderstood.

2 Likes

@ThanhTo
Thank you.
I tried that and confirmed that old XPath located the desired element.
But I could not WebUI.click the old Object that has old XPath.
Using to getAttribute(findTestObject(the old Object), ‘class’), “nav-link dropdown-toggle” that a tag has showed in console and “word-break” that em tag has didn’t show.

xpath

@kazurayam
I misunderstood that. Thank you as always.

Quoting from the W3C WebDriver Specification

If the element is outside the viewport, an element not interactable error is returned.

How about trying WebUI.scrollToElement() to make sure the element is present in the viewport.

WebUI.scrollToElement(findTestObject("Object Repository/webTest/menu/header/provider/em_provider"), 1)
WebUI.click(findTestObject("Object Repository/webTest/menu/header/provider/em_provider"))
1 Like

@kazurayam
Thank you.
I tried to do that, but same error occured.

By Changing XPath, clickable now.

I did re-clicking new XPath Object
'//ul[@class='navbar-nav']/li[1]/a'
or
'//ul[@class='navbar-nav']/li[1]'
, but execution failed.

and tried

WebDriver driver = DriverFactory.getWebDriver()
driver.findElement(By.xpath("//ul/li[1]/a[contains(@class, 'nav-link dropdown-toggle')]")).click()

That also same error happened.

I guess, your page uses Dropdown component of the Bootstrap Navbar.

I guess you want to click one of the item in a Dropdown list.

I found that the list is opened and become visible only when “Dropdown▼” menu is clicked (then the @class=“show” is inserted, that is the way how Bootstrap Navbar works). If “Dropdown▼” menu is not clicked, then the item list stays invisible.

As long as an element is invisible, you can not click it. Yes, an invisible element is present in the DOM, but is not interactable. You would see the “element not interactable” error when you try to click the invisible element.

Possibly you need to click the “Dropdown▼” menu first to make the item list visible, and then click one of the list items.

1 Like

@kazurayam
Certainly that page uses Bootstrap Dropdown component.
Probably I didn’t click Dropdown menu because verifyElementVisible(Object(’//ul/li[1]/a[contains(@class, ‘nav-link dropdown-toggle’)]’)) returns false.
So I’ll modify XPath.

verifyElementVisible the Object that only parent <ul> tag was defined also failed(//ul[@class='navbar-nav']).
There may be other causes.

You should wait for the element to be present in the DOM before checking its visibility. The elements controlled by the Bootstrap framework is dynamically inserted by JavaScript into the DOM, and it takes a few milliseconds. A few milliseconds is long enough and requires you to be careful about timing.

Try WebUI.verifyElementPresent(tObj, t) with 2nd parameter as timeout in seconds.

TestObject tObj = new TestObject().addProperty("xpath", ConditionType.EQUALS, "//ul[@class='navbar-nav']")
WebUI.verifyElementPresent(tObj, 10)
WebUI.verifyElementVisible(tObj)
1 Like

@kazurayam
Thank you.
I tried WebUI.verifyElementPresent(tObj, 30),
but not visible error occured.
Is there a cause for the setting in Katalon?


2020-11-30 18:41:08.359 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Object '' is NOT visible (Root cause: com.kms.katalon.core.exception.StepFailedException: Object '' is NOT visible
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword$_verifyElementVisible_closure1.doCall(VerifyElementVisibleKeyword.groovy:83)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword$_verifyElementVisible_closure1.call(VerifyElementVisibleKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword.verifyElementVisible(VerifyElementVisibleKeyword.groovy:97)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword.execute(VerifyElementVisibleKeyword.groovy:67)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementVisible(WebUiBuiltInKeywords.groovy:373)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementVisible$4.call(Unknown Source)
	at call.run(call:17)
	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:393)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:384)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:363)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:355)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
	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 TempTestCase1606729254532.run(TempTestCase1606729254532.groovy:25)
)
2020-11-30 18:41:08.362 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/webTest/common/call FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Object '' is NOT visible (Root cause: com.kms.katalon.core.exception.StepFailedException: Object '' is NOT visible
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword$_verifyElementVisible_closure1.doCall(VerifyElementVisibleKeyword.groovy:83)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword$_verifyElementVisible_closure1.call(VerifyElementVisibleKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword.verifyElementVisible(VerifyElementVisibleKeyword.groovy:97)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword.execute(VerifyElementVisibleKeyword.groovy:67)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementVisible(WebUiBuiltInKeywords.groovy:373)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementVisible$4.call(Unknown Source)
	at call.run(call:17)
	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:393)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:384)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:363)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:355)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
	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 TempTestCase1606729254532.run(TempTestCase1606729254532.groovy:25)
)
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:39)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword$_verifyElementVisible_closure1.doCall(VerifyElementVisibleKeyword.groovy:83)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword$_verifyElementVisible_closure1.call(VerifyElementVisibleKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword.verifyElementVisible(VerifyElementVisibleKeyword.groovy:97)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementVisibleKeyword.execute(VerifyElementVisibleKeyword.groovy:67)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementVisible(WebUiBuiltInKeywords.groovy:373)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementVisible$4.call(Unknown Source)
	at call.run(call:17)
	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:393)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:384)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:363)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:355)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
	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 TempTestCase1606729254532.run(TempTestCase1606729254532.groovy:25)
Caused by: com.kms.katalon.core.exception.StepFailedException: Object '' is NOT visible
	... 21 more

2020-11-30 18:41:12.313 INFO  .k.c.e.TestExecutionSocketServerEndpoint - MHTML is available at /C:/Users/S_MATS~1/AppData/Local/Temp/Katalon/Test Cases/webTest/common/call/20201130_184054/Test-Cases_webTest_common_call.mhtml
2020-11-30 18:41:13.391 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/webTest/common/call

No. I believe something is wrong in your test case script or the Test Object you created.

If you want me to look at further, please share your Test Case Script, the Test Object and the HTML source (or URL if its public).

If you hesitate to bring your resources exposed, then how about you create a new project against the Bootstrap Navbar page https://getbootstrap.com/docs/4.0/components/navbar/ and try to click an item of a Dropdown list there. You will have a good lesson.

1 Like

Thank you very much.
I’m going to try in Bootstrap Navbar page.

@kazurayam
Executing following the Test Case, that was a success.

Test Case

import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
WebUI.openBrowser('https://getbootstrap.com/docs/4.0/components/navbar/')

TestObject tObj = new TestObject().addProperty("xpath", ConditionType.EQUALS, "//a[@id='navbarDropdown']")
WebUI.verifyElementPresent(tObj, 10)
WebUI.verifyElementVisible(tObj)

WebUI.click(findTestObject('Object Repository/forum/a_Dropdown')) // menu
WebUI.click(findTestObject('Object Repository/forum/a_Action')) // first item of menu

Object Repository/forum/a_Dropdown XPath
//a[@id='navbarDropdown']

Object Repository/forum/a_Action XPath
//div[@id='navbarSupportedContent']/ul/li[3]/div/a[1]

Congrat! You have proved that Katalon Studio can work with a web page with Bootstrap Navbar.
So, have you got any idea how to solve your own problem?

2 Likes

@kazurayam
Yes, I resolved by modifying XPath
//ul/li[1]/a[contains(@class, 'nav-link dropdown-toggle')] or //ul[@class='navbar-nav']/li[1] to
//div[@class='navbar-collapse collapse']/ul/li[1].
It was a good opportunity to learn XPath.
Thank you so much.

1 Like

You can make your XPath expressions better.

Context

You have this HTML fragment in your target web page:

    <div class="nav-bar-collapse collapse">
        <ul>
            <li>...</li>
            ...
        </ul>
    </div>

Your expression //div[@class='navbar-collapse collapse']/ul/li[1] will work well against this HTML.

Problem

However it is likely that sometime your HTML changes like this:

    <div class="collapse nav-bar-collapse">
        ...
    </div>

Please note the value of @class is different from the previous one. But CSS-semantically these are equivalent. Both are valid. Now you got a problem: your current expression //div[@class='navbar-collapse collapse']/ul/li[1] does not work against the changed HTML.

There can be even more annoying case:

    <div class="collapse nav-bar-collapse foo">
        ...
    </div>

How to support these cases by a single XPath expression?

Solution

Use XPath contains() function and logical operator and, rather than @class="alongstring" test.

//div[contains(@class,'navbar-collapse') and contains(@class, 'collapse')]/ul/li[1]
1 Like