Web UI methods marked as passed, while actually they are not passed, when I use Selenium web driver

Good Morning,
I need to launch the chrome driver using selenium, then use it to call Web UI methods in the test cases. the driver launched and opened successfully, but then Web UI methods such as (click, send keys…) in the test cases marked as passed while actually they didn’t, therefore the next step can’t be executed.

it’s noteworthy that the same method sometimes works and sometimes doesn’t.

My Code
def public downloadDocumentSetup() {

	 String OldDownloadsPath=RunConfiguration. getProjectDir () + "/Downloads"
	 String DownloadsPath= OldDownloadsPath.replace("/", "\\")
             HashMap<Object, String> chromePrefs = new HashMap<Object, String>();
	 chromePrefs.put("download.default_directory", DownloadsPath)
	 chromePrefs.put("download.prompt_for_download", false)
	 chromePrefs.put("safebrowsing.enabled", "true");
	 ChromeOptions options = new ChromeOptions()
	 options.setExperimentalOption("prefs", chromePrefs)
	 DesiredCapabilities cap = DesiredCapabilities.chrome()
	 cap.setCapability(ChromeOptions.CAPABILITY, options)
	 System.setProperty("webdriver.chrome.driver", DriverFactory.getChromeDriverPath())
	 WebDriver driver = new ChromeDriver(cap)
	 RunConfiguration. setWebDriverPreferencesProperty ("prefs", chromePrefs)

My Test Case

The browser opened and navigated to the website successfully, and the first click step marked as passed but actually it didn’t pass, therefore the next click action is not working.

My Test case works perfectly when I use ‘Open Browser’ method to launch the driver.

This is going to be something really simple – but my tiny brain can’t see it. :upside_down_face:

Let’s ask the Chrome caps doctor: @Brandon_Hein

One thing I noticed is that you shouldn’t need to do this part:

RunConfiguration.setWebDriverPreferencesProperty ("prefs", chromePrefs)

Once you tell the DriverFactory to use your custom driver, in the line previous to this, you should be good.

You’re right, this is noteworthy, and it points to a timing issue as opposed to your custom driver and capabilities, all of which look fine to me. Can you try and include a timeout in your WebUI calls?:

WebUI.click(findTestObject(‘Pages/MyFirstObject’), 30)
WebUI.click(findTestObject(‘Pages/MySecondObject’), 30)
1 Like

You’re right, it’s timing issue. It seems Selenium driver is faster than katalon, therefore some actions couldn’t be executed correctly, I think timeout can’t be passed as parameter to “click” method, but I can proceed with katalon driver with the desired capabilities and it’s working perfectly.
Thanks for your help

Oh, you are correct, sorry I haven’t looked at the WebUI libs in a long time. Anyway, glad we resolved it. I will mark may answer as the solution. Happy testing!

1 Like