Unable to click on img tag

Hi team,
I am unable to perform click on Img tag event though my xpath is correct. I have used actions, javascript click tooo. but failed to perform click. Below is the screenshot i am attaching .Please help me over this . If it might work with cssSelector, Please give me the cssSelector value


The tObj2 variable in the following code would be useful for you.

import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.model.FailureHandling


/* this XPath often fails to select the Element
TestObject tObj1 = createTestObjectXPath("(//img[@class='option_thumb bgcolorwhite pos_rel']}[1]")
WebUI.verifyElementPresent(tObj1, 5, FailureHandling.CONTINUE_ON_FAILURE)
WebUI.scrollToElement(tObj1, 3)

TestObject tObj2 = createTestObjectXPath("(//img[contains(@class,'option_thumb') and contains(@class,'bgcolorwhite') and contains(@class,'pos_rel')])[2]")
WebUI.verifyElementPresent(tObj2, 5, FailureHandling.CONTINUE_ON_FAILURE)
WebUI.scrollToElement(tObj2, 3)

TestObject tObj3 = createTestObjectCSS('img.option_thumb.bgcolorwhite.pos_rel')
WebUI.verifyElementPresent(tObj3, 5, FailureHandling.CONTINUE_ON_FAILURE)


TestObject createTestObjectXPath(String expr) {
	TestObject tObj = new TestObject(expr)
	tObj.addProperty("xpath", ConditionType.EQUALS, expr)
	return tObj

TestObject createTestObjectCSS(String selector) {
	TestObject tObj = new TestObject(selector)
	tObj.addProperty("css", ConditionType.EQUALS, selector)
	return tObj
  1. An XPath expression //*[@class='foo bar]' is fragile because it fails when the class attribute happens to have a value "bar foo".
    An XPath expression //*[contains(@class,'foo') and contains(@class,'bar')] is robust. It will pass in both cases where the class attribute is "foo bar" or "bar foo".

  2. You should call WebUI.scrollToElement(tObj2, timeout) before WebUI.click() in order to bring the element visible. Otherwise, the element will be invisible and unable to click.

Hi @kazurayam

I have done with both of suggestions, but unable to click element. Here I am attaching the screenshot

I do not see how you tell if you successfully clicked the element or not.
What do you expect to occur when you clicked it?

You can see element got highlighted in mobile. So I can say element is identified but click is not performed

On Mac + Chrome, the img element seems not highlighted. Is it normal?

Its on android, I have written code highlight if element got identified.

Ah, you are testing Android Mobiel App? not a browser WebUI?

I thought you are working of browser WebUI.

Then, you should call “Mobile." keywords, rather than "WebUI.” keywords.

I am testing on mobile browser chrome

When I run my code above on my Mac, my code is successfully clicking the img element. I can notice a thin border in gray color is drawn when clicked. I can not reproduce your problem “but unable to click element”.

The same code is working fine in web browsers but not in mobile browsers

The thin border is nothing but, i am highlighting the elements to know on which element action is going to perform