Context Bar in SalesForce

Ho to all,
I’m trying to test a SalseForce page with Katalon, I can’t to click on the context bar in top of the page and its elements (example: home, chatter, profile…).
I am very inexperienced with Katalon and I have searched more material (frame, webelement, ecc) of katalon in the last days.
Can you help me please?

Thanks!

We need a lot more information about your page. Read this guide:

1 Like

Test_UAT_Class:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import org.openqa.selenium.JavascriptExecutor
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.logging.KeywordLogger
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.common.WebUiCommonHelper
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

//variable
KeywordLogger log = new KeywordLogger()

//navigation
WebUI.openBrowser('')

WebUI.maximizeWindow()

WebUI.navigateToUrl('my-url/')
WebUI.setText(findTestObject('Object Repository/Test20201603/Page_Accedi  Salesforce/input_Nome utente_username'), 'my-email')

WebUI.setEncryptedText(findTestObject('Object Repository/Test20201603/Page_Accedi  Salesforce/input_Password_pw'), 'may-pass')

WebUI.delay(1)
WebUI.click(findTestObject('Object Repository/Test20201603/Page_Accedi  Salesforce/input_Password_Login'))

WebUI.delay(4)

if(findTestObject('Object Repository/TestFrame/Page_Home  Salesforce/Frame_ContextBar'))
{
	log.logInfo("ContextBar found")

	WebUI.delay(4)
	    CustomKeywords.'com.ea.utilities.CommonUtilities.clickUsingJS'(findTestObject('Test20201603/Page_Salesforce/a_Chatter'), 30)
}
WebUI.delay(2)

Common.Utilities.groovy:

package com.ea.utilities

import org.openqa.selenium.JavascriptExecutor
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.common.WebUiCommonHelper
import com.kms.katalon.core.webui.driver.DriverFactory

public class CommonUtilities {
	
	@Keyword
	def clickUsingJS(TestObject to, int timeout)
	{
		System.out.println("test1")
		WebDriver driver = DriverFactory.getWebDriver()
		WebElement element = WebUiCommonHelper.findWebElement(to, timeout)
		System.out.println("test2")
		JavascriptExecutor executor = ((driver) as JavascriptExecutor)
		System.out.println("test3")
		executor.executeScript('arguments[0].click()', Arrays.asList(element))
		System.out.println("test4")
	}
}

My Error:

I would click on “Chatter” fields:

Thanks!

Try adjusting your test object to target the <a> element above, not the <span> shown in your screenshot.

image

1 Like

I’m using already <a element and not <span element, infact my element’s name is “a_Chatter”. Probably I have selected wrong element in html for mistake, sorry.

With your AUT set exactly as the above screenshot, type this in the devtools console:

$0.click()

Let me know what happens.

1 Like

Type this in the browser console:

document.querySelector("one-app-nav-bar-item-root a[title=Chatter]").click()

Hi!

Capture_Katalonhtml4

Weird.

What does this do?

document.querySelector("div.one-appnavbar_appnavbar a[title=Chatter]").click()

Again, make sure you put the page in the same state as your screenshot above.

If there’s a problem, show me what this does…

document.querySelectorAll("one-app-nav-bar-item-root").length
1 Like

Good morning, thank you for your help.

Screen number 1:

Screen number 2:
(in this case I tried with “arguments[1].click()”

Screen number 2.1:
(in this case I use again “arguments[0].click()”

Screen number 3:

Screen number 4:

Why does “Unable to execute Javascript” error appear in screen number 2 (with arguments[1])?
In screen number 2.1 appears instead “arguments[0].click is not a function” (with arguments[0]).

I insert a flag to verify the existence of “Chatter” element:

It returns true.

I think that all javascript code is not recognized, can you explain why?
(below there is an other attempt)

Please don’t deviate from the steps I’m asking you to take. You can play around yourself of course, but don’t post it here without a solution. Thank you.

Are there any iframes on this page? Is the section of HTML in your screenshot inside an iframe? (the screenshot I have been dealing with, not the new stuff you posted above).

document.querySelectorAll("iframe").length