# Issue clicking web element in salesforce lightning

**URL:** <https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [October 8, 2019, 2:27pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318 "2019-10-08T14:27:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 8, 2019, 2:27pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/1 "2019-10-08T14:27:40Z")

</div>

Hi guys,

I ran into the similar problem as described in: [I am not able to click on a web element in salesforce lightning application](http://forum.katalon.com/t/i-am-not-able-to-click-on-a-web-element-in-salesforce-lightning-application/22461)

I tried the solution provided there and change the links/objects accordingly to my situation:

```
// Wait upto 10 seconds for a_Accounts to be visible...
WebUI.waitForElementVisible(findTestObject('Local_OPP/Page_Home Salesforce/span_Opportunities'), 10)

// Wait an additional, full 10 seconds...
/* *******/ WebUI.delay(10) /******* */

WebUI.executeJavaScript('''document.querySelector('a[href="/lightning/o/Opportunity/home"] > span').click()''', null)

// this was original solution from recording
// WebUI.click(findTestObject('Local_OPP/Page_Home Salesforce/span_Opportunities'))

```

But when I play the test case, error occurs:  
10-08-2019 04:03:22 PM Test Cases/INTPack/New Opportunity object

Elapsed time: 25.214s

```
Test Cases/INTPack/New Opportunity object FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to execute JavaScript.
	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.ExecuteJavaScriptKeyword.executeJavascript(ExecuteJavascriptKeyword.groovy:42)
	at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.execute(ExecuteJavascriptKeyword.groovy:37)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.executeJavaScript(WebUiBuiltInKeywords.groovy:3787)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$executeJavaScript$5.call(Unknown Source)
	at New Opportunity object.run(New Opportunity object:34)
	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 TempTestCase1570543399782.run(TempTestCase1570543399782.groovy:21)
Caused by: org.openqa.selenium.JavascriptException: javascript error: Cannot read property 'click' of null
  (Session info: chrome=76.0.3809.132)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'LTCZAEBS9RTMPQ2', ip: '10.46.3.13', 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: 76.0.3809.132, chrome: {chromedriverVersion: 76.0.3809.68 (420c9498db8ce..., userDataDir: C:\Users\LUKAS~1.RER\AppDat...}, goog:chromeOptions: {debuggerAddress: localhost:54800}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 6f6b6a4055d58518462a0c384bbbc367
	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:20)
	at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:489)
	at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword$_executeJavascript_closure1.doCall(ExecuteJavascriptKeyword.groovy:48)
	at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword$_executeJavascript_closure1.call(ExecuteJavascriptKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	... 17 more
```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [October 8, 2019, 2:38pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/2 "2019-10-08T14:38:12Z")

</div>

This part of the error is what matters:

> [@lukas.rericha](#):
>
> Caused by: org.openqa.selenium.JavascriptException: javascript error: Cannot read property ‘click’ of null

That means, `'a[href="/lightning/o/Opportunity/home"] > span'` is not a valid object (it’s null).

You can confirm this in your browser console. Bring up the page, and paste this in the browser console:

```auto
document.querySelector('a[href="/lightning/o/Opportunity/home"] > span')

```

Run that and post a screenshot of the results.

I’m also concerned about this:

> [@lukas.rericha](#):
>
> I tried the solution provided there and change the links/objects accordingly to my situation

Can you please provide “your situation”. I.e. show me your code and a screenshot of the relevant HTML.

Thanks

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 9, 2019, 7:17am UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/3 "2019-10-09T07:17:29Z")

</div>

> [@Russ\_Thomas](#):
>
> an confirm this in your browser console

Ok, thought it’s just a link, not an object. I’ll look into that during the day, still newbie, dunno where to find console 🙂

Just short update before I get back with results: original solution worked, when I used absolute XPath from ChroPath (both relative XPath and CSS fails).

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [October 9, 2019, 10:52am UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/4 "2019-10-09T10:52:14Z")

</div>

Console et al can be found here:

[http://forum.katalon.com/t/how-to-the-browser-developer-tools-f12-devtools/34329?u=russ\_thomas](http://forum.katalon.com/t/how-to-the-browser-developer-tools-f12-devtools/34329)

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 9, 2019, 11:44am UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/5 "2019-10-09T11:44:37Z")

</div>

> [@Russ\_Thomas](#):
>
> document.querySelector(‘a[href=“/lightning/o/Opportunity/home”] \> span’)

Thanks, did not knew there was a console in this Tab. So the output of the JS code in console is only: “null”. But that’s weird, in screen you can see exactly the same link.

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/7/7f09324d8bcbe0ecc6080e3e72927770779008fd.png)

Lower you can find whole code:

```
WebUI.openBrowser('')

WebUI.navigateToUrl('https://test.salesforce.com/')

WebUI.setText(findTestObject('Object Repository/Local_OPP/Page_Login Salesforce/input_Username_username'), 'branchuser1@yopmail.com.focore.intv2')

WebUI.setEncryptedText(findTestObject('Object Repository/Local_OPP/Page_Login Salesforce/input_Password_pw'), '3Z9vEXbPUsBb8kkQDDKxXw==')

WebUI.click(findTestObject('Object Repository/Local_OPP/Page_Login Salesforce/input_Password_Login'))

// Wait upto 10 seconds for a_Accounts to be visible...
WebUI.waitForElementVisible(findTestObject('Local_OPP/Page_Home Salesforce/span_Opportunities'), 10)

// Wait an additional, full 10 seconds...
/* *******/ WebUI.delay(10) /******* */

WebUI.executeJavaScript('''document.querySelector('a[href="/lightning/o/Opportunity/home"] > span').click()''', null)

// WebUI.click(findTestObject('Local_OPP/Page_Home Salesforce/span_Opportunities'))

WebUI.click(findTestObject('Object Repository/Local_OPP/Page_Recently Viewed Opportunities Salesforce/div_New'))

```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [October 9, 2019, 11:56am UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/6 "2019-10-09T11:56:56Z")

</div>

> [@lukas.rericha](#):
>
> So the output of the JS code in console is only: “null”

Sounds like it’s in an iframe. And this seems to confirm it:

> [@lukas.rericha](#):
>
> original solution worked, when I used absolute XPath from ChroPath (both relative XPath and CSS fails).

In the browser console again:

```auto
frames.length

```

We’re hoping for zero, but I’m guessing it’s not.

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 9, 2019, 12:05pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/7 "2019-10-09T12:05:16Z")

</div>

console answer is 1

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [October 9, 2019, 12:18pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/8 "2019-10-09T12:18:09Z")

</div>

So now you (we) need to prove that `<a href=...>` is residing _inside_ the `<iframe...>` element.

Return to your DevTools, find the `<a href=...>` element and “walk” up the tree until you find the `<iframe>` element. When you find it, take another screenshot - try to show both the iframe and the a-element in the same shot.

My intention is to build you some JS/CSS to reach the a-element. I need to see the entire “scope” to do that.

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 9, 2019, 12:33pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/9 "2019-10-09T12:33:01Z")

</div>

No, no iframe tag found, until the top of this DevTool screen (until the beginning doctype html tag). I screened max of the code - I would paste whole, but did not found a way how to copy it from the DevTool. If it’s just the html page I guess I can copy it from there.

Weird thing is, that when I used yesterday Katalon Recorder extension for Chrome, I did not have problem with this part. And second weird thing is, that this object is in the same menu, as the problem I linked in my first post.

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/e/e31d109e17891f7019c8cb715995bcb489ceea8c.png)

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [October 9, 2019, 1:00pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/10 "2019-10-09T13:00:02Z")

</div>

Try this in the console. Send me a screenshot of the output:

```auto
document.querySelector("a[href='/lightning/o/Opportunity/home']").click()

```

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 9, 2019, 1:42pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/11 "2019-10-09T13:42:18Z")

</div>

Console result is: Uncaught TypeError: Cannot read property ‘click’ of null at \<anonymous\>:1:66

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [October 9, 2019, 1:48pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/12 "2019-10-09T13:48:20Z")

</div>

Well, at least it’s consistent.

I’m starting to wonder if there’s some shadow dom trickery going on here. I honestly think I’ve reached the end of my remote debugging skills.

I have to ask, what prompted you to move from the absolute paths? Did you say that those worked?

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 9, 2019, 1:52pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/13 "2019-10-09T13:52:30Z")

</div>

I was just trying what will work, that’s how I found the absolute Xpath. But from what I’ve read, the absolute Xpath will probably crash with new SalesForce update.

So I am currently in my “PoC” stage - if it makes sense in our company to make the Katalon implementation bigger. If I fail on first scenario recording and will know that I will need to debug the tests with each update because of absolute Xpaths, the business case will suffer a blow…

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 9, 2019, 1:54pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/14 "2019-10-09T13:54:15Z")

</div>

Other question - can I somehow import the recording from Chrome extension to Katalon studio? I need to edit it because of the dynamic IDs on pop-up screens (I’ve read solution in another topic). But the problem is, I could not edit these things in the extension. And export seemed in kind of weird HTML filetype…

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [October 9, 2019, 2:00pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/15 "2019-10-09T14:00:53Z")

</div>

> [@lukas.rericha](#):
>
> So I am currently in my “PoC” stage - if it makes sense in our company to make the Katalon implementation bigger. If I fail on first scenario recording and will know that I will need to debug the tests with each update because of absolute Xpaths, the business case will suffer a blow…

Well, you shouldn’t allow my failure to help you judge the merits of Katalon Studio. Sitting in front of your PC, I’d very likely have this working in 5 minutes.

Let’s try a callout to some other people - hopefully a fresh set of eyes will find something I missed.

@Ibus @Brandon_Hein @ThanhTo @devalex88

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 9, 2019, 2:04pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/16 "2019-10-09T14:04:22Z")

</div>

@Russ_Thomas Don’t worry and thanks for help. I see Katalon as powerful tool, but the recording part has gaps, whatever the solution of this problem is.

---

<div class="post-metadata">

**Author:** ![devalex88](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/devalex88/32/336_2.png) [@devalex88](https://forum.katalon.com/u/devalex88)\
**Post date:** [October 10, 2019, 3:30am UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/17 "2019-10-10T03:30:06Z")

</div>

Please try `window.frames[0].document.querySelector("a[href='/lightning/o/Opportunity/home']")` in the console and let me know the result.

---

<div class="post-metadata">

**Author:** ![lukas.rericha](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@lukas.rericha](https://forum.katalon.com/u/lukas.rericha)\
**Post date:** [October 11, 2019, 7:25am UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/18 "2019-10-11T07:25:11Z")

</div>

Response of console is: null

---

<div class="post-metadata">

**Author:** ![devalex88](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/devalex88/32/336_2.png) [@devalex88](https://forum.katalon.com/u/devalex88)\
**Post date:** [October 11, 2019, 7:40am UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/19 "2019-10-11T07:40:45Z")

</div>

If possible please copy the whole HTML and send me. You can send a private message if it is sensitive.

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/e/e22587b9a800d29aa94590bd08bf77df34e39c14.png)

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [October 11, 2019, 12:14pm UTC](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318/20 "2019-10-11T12:14:59Z")

</div>

@lukas.rericha

In addition to what you’re doing for @devalex88, please try this…

Run your stuff against Firefox and try the same things in the console. If you see any significant difference, we’d like to see what those are. You can choose any of the console things… doesn’t matter which ones.

[Next page](https://forum.katalon.com/t/issue-clicking-web-element-in-salesforce-lightning/34318.md?page=2)
