Unable to click button and set text to popup modal

Hi all,
I am doing an school project of making an automation test script for website: https://www.ourbetterworld.org/.
I am having problem with clicking and entering text to the login pop-up modal.
I have tried JavascriptExecuter, using record and playback function of Katalon and even switch frame but no success.

Below is my code:
@Keyword
def clickButtonJavascript(String xpath) {
try {
WebDriver driver = DriverFactory.getWebDriver();
WebElement element =driver.findElement(By.xpath("//input[@id=“edit-submit–HMiO5lhxV9Y”]"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript(“arguments[0].click()”,element);
KeywordUtil.markPassed(“Element has been clicked”);
} catch (WebElementNotFoundException e) {
KeywordUtil.markFailed(“Element not found”)
} catch (Exception e) {
KeywordUtil.markFailed(“Fail to click on element”)
}
}

Error log:
2019-06-30 16:58:23.754 DEBUG testcase.TC_1 - 3: modalKeyword.SelectByJavascript.clickButtonJavascript("//input[@id=“edit-submit–HMiO5lhxV9Y”]")
2019-06-30 16:58:23.785 ERROR com.kms.katalon.core.util.KeywordUtil - :x: Fail to click on element
2019-06-30 16:58:23.787 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: com.kms.katalon.core.exception.StepFailedException: Fail to click on element
2019-06-30 16:58:23.797 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Feature_TestCase/TC_1 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 modalKeyword.SelectByJavascript.clickButtonJavascript(SelectByJavascript.groovy:26)
at modalKeyword.SelectByJavascript.invokeMethod(SelectByJavascript.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at TC_1.run(TC_1:20)
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 TempTestCase1561888694605.run(TempTestCase1561888694605.groovy:21)

The element of the button
input class=“use-ajax button js-form-submit form-submit” data-drupal-selector=“edit-submit” type=“submit” id=“edit-submit–HMiO5lhxV9Y” name=“op” value=“Login” style=“display: block; width: 0px; height: 0px; padding: 0px; border: 0px; overflow: hidden;”

The screenshot:


Any help is really appreciated. Thanks you all beforehand.

I believe one of your problems is that you’re using the id attribute to try and locate the button, but the id attribute value is dynamic:

edit-submit–HMiO5lhxV9Y

The part in bold above will change each time you access the page. For instance, I’m looking at the id right now and this is what I’ve got:

image

Try using this xpath instead, which I was able to click with webdriver without a problem:

driver.findElement(By.xpath("//input[@value='Login']")).click()

I tried to use that xpath but it still failed. I also tried the relative xpath: (.//*[normalize-space(text()) and normalize-space(.)=‘The Password’])[1]/following::input[2]

Error code:
2019-07-02 00:00:17.854 DEBUG testcase.TC_1 - 3: actionKeyword.SelectByXPathKeyword.clickElementByXPath("(.//*[normalize-space(text()) and normalize-space(.)=‘The Password’])[1]/following::input[2]")
2019-07-02 00:00:17.896 ERROR com.kms.katalon.core.util.KeywordUtil - :x: Fail to click on element
2019-07-02 00:00:17.899 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: com.kms.katalon.core.exception.StepFailedException: Fail to click on element
2019-07-02 00:00:17.915 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Feature_TestCase/TC_1 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.clickElementByXPath(SelectByXPathKeyword.groovy:82)
at actionKeyword.SelectByXPathKeyword.invokeMethod(SelectByXPathKeyword.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at TC_1.run(TC_1:20)
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 TempTestCase1562000408025.run(TempTestCase1562000408025.groovy:21)

Thanks man for your help @Brandon_Hein

Can you either:

1.) Try clicking on it just using webdriver, without your custom keyword.

or

2.) Print the stack trace in your try/catch block, so that I can see what the actual cause of the error is:

def clickButtonJavascript(String xpath) {
    try {
        // Do stuff...
    } catch (WebElementNotFoundException e) {
        e.printStackTrace()
        KeywordUtil.markFailed(“Element not found”)
    } catch (Exception e) {
        e.printStackTrace()
        KeywordUtil.markFailed(“Fail to click on element”)
    }
}

Thanks.

Hi @Brandon_Hein,
Below is the error log of the 2 options you mention:
1st option:
SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
2019-07-02 21:25:14.331 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2019-07-02 21:25:14.335 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/Feature_TestCase/New Test Case
2019-07-02 21:25:14.926 DEBUG testcase.New Test Case - 1: openBrowser("")
2019-07-02 21:25:15.235 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome’ driver
Jul 02, 2019 9:25:15 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2019-07-02 21:25:15.277 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 seconds
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 10196
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1562077517.191][WARNING]: This version of ChromeDriver has not been tested with Chrome version 75.
Jul 02, 2019 9:25:18 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
2019-07-02 21:25:18.270 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = a434fd612e04064821be3778141a245d
2019-07-02 21:25:18.301 INFO c.k.k.core.webui.driver.DriverFactory - browser = Chrome 75.0.3770.100
2019-07-02 21:25:18.301 INFO c.k.k.core.webui.driver.DriverFactory - platform = Windows 8.1
2019-07-02 21:25:18.302 INFO c.k.k.core.webui.driver.DriverFactory - seleniumVersion = 3.141.59
2019-07-02 21:25:18.303 INFO c.k.k.core.webui.driver.DriverFactory - proxyInformation = ProxyInformation{proxyOption=NO_PROXY, proxyServerType=HTTP, password=, proxyServerAddress=, proxyServerPort=0}
2019-07-02 21:25:18.307 DEBUG testcase.New Test Case - 2: navigateToUrl(“https://www.ourbetterworld.org/”)
2019-07-02 21:25:21.054 DEBUG testcase.New Test Case - 3: click(findTestObject(“Object Repository/Page_Our Better World We tell stories of good/a_Log In”))
2019-07-02 21:25:21.204 DEBUG testcase.New Test Case - 4: click(findTestObject(“Object Repository/Page_Our Better World We tell stories of good/input_The Password_op”))
2019-07-02 21:25:22.271 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to click on object ‘Object Repository/Page_Our Better World We tell stories of good/input_The Password_op’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Our Better World We tell stories of good/input_The Password_op’
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:86)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$1.call(Unknown Source)
at New Test Case.run(New Test Case:22)
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 TempTestCase1562077512282.run(TempTestCase1562077512282.groovy:21)
Caused by: org.openqa.selenium.ElementNotVisibleException: element not interactable
(Session info: chrome=75.0.3770.100)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘NGUYENTHUC’, ip: ‘192.168.1.118’, os.name: ‘Windows 8.1’, os.arch: ‘amd64’, os.version: ‘6.3’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 74.0.3729.6 (255758eccf3d24…, userDataDir: C:\Users\hidadsek\AppData\L…}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:49169}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 75.0.3770.100, webStorageEnabled: true}
Session ID: a434fd612e04064821be3778141a245d
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
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:20)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:79)
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:86)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$1.call(Unknown Source)
at Script1561998990899.run(Script1561998990899.groovy:22)
… 11 more
)
2019-07-02 21:25:22.279 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Feature_TestCase/New Test Case FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Our Better World We tell stories of good/input_The Password_op’
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:86)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$1.call(Unknown Source)
at New Test Case.run(New Test Case:22)
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 TempTestCase1562077512282.run(TempTestCase1562077512282.groovy:21)
Caused by: org.openqa.selenium.ElementNotVisibleException: element not interactable
(Session info: chrome=75.0.3770.100)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘NGUYENTHUC’, ip: ‘192.168.1.118’, os.name: ‘Windows 8.1’, os.arch: ‘amd64’, os.version: ‘6.3’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 74.0.3729.6 (255758eccf3d24…, userDataDir: C:\Users\hidadsek\AppData\L…}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:49169}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 75.0.3770.100, webStorageEnabled: true}
Session ID: a434fd612e04064821be3778141a245d
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
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:20)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:79)
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

2019-07-02 21:25:22.288 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/Feature_TestCase/New Test Case

2nd option:
SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
2019-07-02 21:12:51.586 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2019-07-02 21:12:51.590 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/Feature_TestCase/TC_1
2019-07-02 21:12:52.159 DEBUG testcase.TC_1 - 1: openBrowser(“https://www.ourbetterworld.org/”)
2019-07-02 21:12:52.430 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome’ driver
Jul 02, 2019 9:12:52 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2019-07-02 21:12:52.476 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 seconds
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 48706
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1562076774.296][WARNING]: This version of ChromeDriver has not been tested with Chrome version 75.
Jul 02, 2019 9:12:55 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
2019-07-02 21:12:55.445 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = 294634a5d0f8dfcdbcbc45d876f0b86a
2019-07-02 21:12:55.480 INFO c.k.k.core.webui.driver.DriverFactory - browser = Chrome 75.0.3770.100
2019-07-02 21:12:55.481 INFO c.k.k.core.webui.driver.DriverFactory - platform = Windows 8.1
2019-07-02 21:12:55.481 INFO c.k.k.core.webui.driver.DriverFactory - seleniumVersion = 3.141.59
2019-07-02 21:12:55.483 INFO c.k.k.core.webui.driver.DriverFactory - proxyInformation = ProxyInformation{proxyOption=NO_PROXY, proxyServerType=HTTP, password=, proxyServerAddress=, proxyServerPort=0}
2019-07-02 21:12:59.183 DEBUG testcase.TC_1 - 2: actionKeyword.SelectByXPathKeyword.clickElementByXPath("//li[@class=‘login’]")
2019-07-02 21:12:59.374 DEBUG com.kms.katalon.core.util.KeywordUtil - ✓ Element has been clicked
2019-07-02 21:12:59.375 DEBUG testcase.TC_1 - 3: actionKeyword.SelectByXPathKeyword.clickElementByXPath("//input[@value=‘Login’]")
2019-07-02 21:12:59.407 ERROR com.kms.katalon.core.util.KeywordUtil - :x: Fail to click on element
2019-07-02 21:12:59.409 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: com.kms.katalon.core.exception.StepFailedException: Fail to click on element
2019-07-02 21:12:59.427 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Feature_TestCase/TC_1 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.clickElementByXPath(SelectByXPathKeyword.groovy:82)
at actionKeyword.SelectByXPathKeyword.invokeMethod(SelectByXPathKeyword.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at TC_1.run(TC_1:20)
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 TempTestCase1562076769590.run(TempTestCase1562076769590.groovy:21)

2019-07-02 21:12:59.434 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/Feature_TestCase/TC_1

Thanks and best regards to you.

This means the element you’re trying to target is not “ready”. Try waiting until it is visible.

(I’ll defer to Brandon for finer detail - I didn’t read the whole thread).

2 Likes

As Russ said, it’s because the element isn’t visible at the time of the click.

When I was on your site, I noticed that it takes a second for the actual login modal window to appear after clicking the “Login” button at the top. Therefore, you will need to wait for an element in that modal to become visible, then try and click. Using webdriver, that might look like:

WebElement button = driver.findElement(By.xpath("//input[@value='Login']"));
new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOf(button));
button.click()
3 Likes

Thanks you guys, this issue is resolved.
It is kind of weird that explicit wait doesn’t work but Implicit wait and Thread.sleep works like a charm.
For using Records, adding step waitForElementVisible makes it work.
Thanks again for your help @Brandon_Hein and @Russ_Thomas. Have a nice day

2 Likes