May I lend some help to solve about get web elements

Hello everyone, first of all thank you for spending your time to help me.
I am trying to test website https://magento.softwaretestingboard.com to improve my skills. I am creating a script to verify my searching item, but I have been stuck on this error for around 5 hours have not yet found a solution.

The issue I have been found is I cannot get the text element(get web element).
I am using WebUI.findWebElement and WebUI.getText but still they do not return the text. I also use locator as //a[@class="product-item-link"] and //a[contains(text(),'Jacket')] but still do not return the text.

1 Like

This sentence does NOT describe what you did. You should

  1. Show the source code of your test script, with highlighting the lines you think problematic. You should not trim the lines too much.

  2. Show the HTML source with highlighting the HTML element you are interested in

Without lookig at the source code, it is impossible to suggest anything practical.


By the way, the title of your post “May I lend …” is a unnecessary salutation. It does not describe your problem. The title should be more pragmatic; describe your problem in it; that would be enough. No hello, no thanks in the titles please.

1 Like

Are you sure the problem isn’t your println statement? Your string and variable need to be within brackets, eg println(“Item is:” + item)

2 Likes

oh… My wrong. Thank you for taking the time to help me.

I apologize for my lack of explanation. This is my code step:

  1. I write to get a whole elements about “Jacket” on result search page and using locator //a[@class="product-item-link"] to get hole item result
  2. Writing scrip as:
WebUI.openBrowser('https://magento.softwaretestingboard.com')

TestObject searchInput = findTestObject('Object Repository/SearchPage/SearchInput')
WebUI.setText(searchInput, 'Jacket')
WebUI.sendKeys(searchInput, Keys.chord(Keys.ENTER))

TestObject searchResults = findTestObject('Object Repository/SearchPage/SearchResults')
WebUI.waitForElementVisible(searchResults, 10)

List<WebElement> jacketElements = WebUI.findWebElements(searchResults)

List<String> jacketTextValues = []
for (WebElement jacketElement : jacketElements) {
    String jacketText = jacketElement.getText()
    jacketTextValues.add(jacketText)
}

for (String value : jacketTextValues) {
    println ("Jacket item: " + value)
}

WebUI.closeBrowser()

And what is your current problem? Any error log have you got? What did you expect to see and what did you actually see?

Thank you for your help again. I really appreciated it.

I expected to see a result as a list of items that I would split only as “jacket,” but I did not get any return because of the findWebElement error.
Error: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.getText() is applicable for argument types: (org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement)

Your code is:

List<WebElement> jacketElements = WebUI.findWebElements(searchResults)

You should check the documentation of the findWebElements keyword at

You should find that this keyword requires 2 parameters. But your script is providing only 1 parameter. Therefore it fails.

You should read the docs carefully.


Why not you change the title of this post?

2 Likes

Thank you for pointing that out! I appreciate your feedback. I’ll make sure to read the documentation more carefully. Also, I’ll take your suggestion to heart and consider changing the title. Thanks again for your assistance!

1 Like