Unable to click button with element xpath id's objects

HI There , @“Katalon Studio”

Just used this 2 days ago and i am a huge fan. Love the Vietnamese culture as well. ( Luv the coffee! ) you guys are on a right path for this.

i got an issue on some scripting/recording where it is unable to click on on link button with a href javascript.Hoping perhaps someone or somebody can assist.

Using:
Katalon 4.8 Win64 build 2.
firefox 56 ( **wires **)

Error Log:

10-12-2017 11:04:30 AM - [FAILED] - Unable to click on object ‘Object Repository/Extend object/Page_Home/a_Create Report’ (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Extend object/Page_Home/a_Create Report’ located by ‘By.xpath: id(“t_TreeNav_1”)/div[@class=“a-TreeView-content is-hover”]/a[@class=“a-TreeView-label”]’ not found)

&

10-12-2017 11:12:02 AM - [FAILED] - Unable to click on object ‘Object Repository/Extend object/Page_Home/span_fa icon-add’ (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Extend object/Page_Home/span_fa icon-add’ located by ‘By.xpath: //span[count(. | id(“t_TreeNav_1”)/div[@class=“a-TreeView-content is-hover”]/span[@class=“fa icon-add”]) = count(id(“t_TreeNav_1”)/div[@class=“a-TreeView-content is-hover”]/span[@class=“fa icon-add”])]’ not found)

i’ve tried these below

</>Script

WebUI.waitForElementVisible(findTestObject(‘Extend object/Page_Home/span_BAB15A (1)’), 0)

WebUI.delay(3)

WebUI.verifyElementClickable(findTestObject(‘Extend object/Page_Home/span_fa icon-add’))

not_run: CustomKeywords.‘clickJS2.clickusingjs2.clickUsingJS2’(findTestObject(‘Extend object/Page_Home/a_Create Report’),
0)

not_run: WebUI.click(findTestObject(‘Extend object/Page_Home/a_Create Report’))

not_run: WebUI.clickOffset(findTestObject(‘Extend object/Page_Home/a_Create Report’), 100, 100)

not_run: CustomKeywords.‘clickJS2.clickusingjs2.clickUsingJS2’(findTestObject(‘Extend object/Page_Home/a_Create Report’), 100, 100)



Using these Objects

div_a-TreeView-content is-hove

xpath = id(“t_TreeNav_1”)/div[@class=“a-TreeView-content is-hover”]
class = a-TreeView-content is-hover

a_Create Report

xpath = id(“t_TreeNav_1”)/div[@class=“a-TreeView-content is-hover”]/a[@class=“a-TreeView-label”]
href =
javascript:apex.navigation.dialog(‘f?p=123:4:7575820123781::NO:::\u0026p_dialog_cs=lNaIOfjWHa78dUH1Pl–MLMbjWwGSHIBuGliRolCURViYanZb1P282WoWxzf3PtE-5GKPRngVf5hsiBG-thI-Q’,{title:‘Name your Report’,height:‘300’,width:‘500’,maxWidth:‘960’,modal:true,dialog:null},‘t-Dialog–wizard’,apex.jQuery(‘#t_Body’));
text Create Report
class a-TreeView-label

span_fa icon-add

xpath= id(“t_TreeNav_1”)/div[@class=“a-TreeView-content is-hover”]/span[@class=“fa icon-add”]
class= fa icon-add




Using JSexecuter

package clickJS2

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testcase.TestCaseFactory
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

import internal.GlobalVariable

import MobileBuiltInKeywords as Mobile
import WSBuiltInKeywords as WS
import WebUiBuiltInKeywords as WebUI
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import org.openqa.selenium.interactions.Actions as Actions
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.JavascriptExecutor as JavascriptExecutor

public class clickusingjs2 {
@Keyword
def clickUsingJS2 (TestObject to, int timeout) {

	try {
		WebUI.click(to)
	}
	catch (Exception e) {
		WebDriver driver = DriverFactory.getWebDriver()
		WebElement element = WebUiCommonHelper.findWebElement(to, timeout)
		JavascriptExecutor executor = ((driver) as JavascriptExecutor)
		executor.executeScript('arguments[0].click()', element)
	}
	throw(e)
}


So i’ve used the “click” keyword and the JScriptexecutor. however i am still unable to click the element.Is there any other option where i can be able to click the class or element?

Appreciate the help/assistance

Bern

2017-10-11_22h45_31.png

2017-10-12_11h15_04.png

2017-10-12_11h16_19.png

Hey there,

How about using ‘CSS selector’ instead:

  1. Get CSS selector value of those 2 objects. You can grab it using this add-on: https://chrome.google.com/webstore/detail/copy-css-selector/kemkenbgbgodoglfkkejbdcpojnodnkg?hl=en
  2. Edit test object of these objects by adding ‘css’ key with value gotten from above, e.g:

Screen Shot 2017-10-12 at 11.57.01.png

@Hanh Tran

Thank you so much. that worked. :slight_smile:

@“Hanh Tran” @hanh can you help y problem

Test Cases/login FAILED because (of) Unable to click on object ‘Object Repository/Page_Data Penjualan/span_Tambah’ (Root cause: org.openqa.selenium.ElementNotVisibleException: element not visible

(Session info: chrome=63.0.3239.132)

(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 0 milliseconds

Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’

System info: host: ‘AKBAR-PC’, ip: ‘192.168.56.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_102’

Driver info: com.kms.katalon.selenium.driver.CChromeDriver

Capabilities {acceptSslCerts: true, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.33.506120 (e3e53437346286…, userDataDir: C:\Users\popy\AppData\Local…}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 63.0.3239.132, webStorageEnabled: true}

Session ID: 16RdyEv2g73dMgnpGDf2cs5n2LGuRgNAX1041708)