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


#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!


#2

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


#3

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


#4

Thanks for the feedback.

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

Below the pictures:


#5

Add…

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

then…

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

#6

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

Below images:


#7

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


#8

You did this.

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

This would not work.

Try the following:

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

#9

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


#10

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


#11

Same error. :frowning_face:


#12

Nope. I just tried it.


#13

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?


#14

possibly also add this

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


#15

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.


Unable to resolve class WebElement when Recording? Please help
#16

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

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.


#17

Thanks for the feedback.