How to use Selenium webdriver and webElement in Katalon Studio 6.1?

I tried to use the script to read cells from the html table as follows link.

When running the test katalon does not recognize the WebElement causing the error: unable to resolve class WebElement.

Could you please help me?
Thank you!

Please follow the advice here, then someone may be able to help you:

In script view, add import org.openqa.selenium.WebElement as WebElement
And all others import from the example in the link

Thanks for the feedback.

In my test case I have this import but it still does not work.

Below the pictures:

Add…

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

then…

WebDriver driver = DriverFactory.getWebDriver()
WebElement Table = driver.findElement(...

I altered but continues with the same error. It does not recognize imports org.openqa.selenium.

Below images:

Here’s you can go:

  1. Create a WebDriver instance.
  2. Navigate to a Web page.
  3. Locate an HTML element on the Web page.
  4. Perform an action on an HTML element.
  5. Anticipate the browser response to the action.

Source

You did this.

WebDriver driver = DriverFactory.getWebDriver()
WebUI.openBrowser('')

This would not work.

Try the following:

WebUI.openBrowser('')
WebDriver driver = DriverFactory.getWebDriver()
1 Like

I removed all remaining code and left only the browser’s opening call and the WebDriver statement and the error continues.

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

Same error. :frowning_face:

Nope. I just tried it.

I changed the import and had the same error. Katalon does not recognize any Selenium import. Do I need to install some extension to work?

possibly also add this

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

In the screenshot you attached, I found you are using the Web Recorder dialog to run your Test Case. This is a mistake.

You are likely to encounter failures for importing org.openqa.selenium.* classes, as the Web Recorder dialog is designed specifically for letting Katalon Studio to generate codes which simulate Web UI operation. Web Recorder is not a tool for general purpose programming. I suppose that the classpath of the Web Recorder dialog is not configured to include the jar of the WebDriver. Therefore, in the Web Recorder dialog, you are possibly not granted with immediate reference to the org.openqa.selenium.* classes.

You shouldn’t use the Web Recorder dialog to write and run your generic test case script. Alternatively we usually use the green run button in the main tool bar of Katalon GUI image2018-4-16-183A213A34 as documented in

https://docs.katalon.com/katalon-studio/docs/toolbars-and-views.html#toolbar

Please try the usual green run button, then I suppose you would no longer see errors of importing org.openqa.selenium.* classes.

But be prepared to get some different error messages … your life goes on.

1 Like

Thanks for the feedback.