Clicking on a button element is not actually clicking it

Upon testing a page that has a submit button that, when clicked, is to display a loading screen followed by the status of the input, at the step where it is to Click the button, the button gets focused on, but not actually clicked. (There’s a light blue border around the button to be clicked, instead of the loading screen.) When I manually click it, outside the automated test, the button actually gets clicked, and the screen shows as expected.

How do I remedy this?

The Test Object that I tell the test to Click has a valid selector (it’s a CSS selector consisting of #[the id of the button]), that I have verified both by inspecting the DOM and using jQuery.

Hey Michael

Instead of using a Test Object, try executing a click in JavaScript/jQuery (I do this all the time since it’s more reliable). You do, of course, need to ensure first that JavaScript/jQuery are “ready”.

You will need to create a Keyword class: https://docs.katalon.com/display/KD/Define+custom+keywords and add a method something like…

  /**
   * Click an element using jQuery.
   * @param selector (String) jQuery selector to target the element.
   * @param iFrameSelector (string) optional iframe selector.
   */
  static void jQ_click(String selector, String iFrameSelector = null) {
    comment('jQ_click clicking ' + selector)
    String js = "\$(arguments[0]).click();"
    if(iFrameSelector) {
      js = "\$(arguments[1]).contents().find(arguments[0]).click();"
    }
    WebUI.executeJavaScript(js, Arrays.asList(selector, iFrameSelector))
  }


Then pass in your selector like this:

jQ_click("#your-id")

Hope that helps.

2 Likes

@Russ_Thomas i am also getting similar problem, i used java script to click on a ‘Create’ button in my application, it clicks the button and on the button it comes as ‘processing’.
When i click this button in my application it navigates to other page and this is what i expect it to do with karalon.
String jw = ‘document.querySelector('#ctl00_Toolbar_btnOK').click()’
WebUI.executeJavaScript(jw, null)

image

Another thing is i am getting pop up alert saying ‘button found’ when i click using java script but this alert does not come in actual application.

Please help me resolve this

Please post a new topic/question. Thanks.