Example: In a page, some elements have text = ‘coach 1’. I want to count all elements have this text but I don’t know how do that?
Thanks a lot!!!
@anhvu.nguyenqn90 said:
Example: In a page, some elements have text = ‘coach 1’. I want to count all elements have this text but I don’t know how do that?
Hi Vu,
I am having same issue and can’t find the solution. Please tell me how you resolved that? I am waiting for your reply.
Same Question here, how to work with findElements in Katalon studio?
Same question, is there a solution or a workaround for this?
@Narendra said:
Same Question here, how to work with findElements in Katalon studio?
WebDriver driver = DriverFactory.getWebDriver();
After this you can proceed with findElements method.
It should be like this:
import org.openqa.selenium.WebDriver
import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.By
WebDriver driver = DriverFactory.getWebDriver()
eleCount = driver.findElements(By.xpath("//*[text()='Coach 1'])).size()
Hi all, someone has a solution for this?
I am using the following, but doesn’t work:
WebUI.getNumberOfTotalOption(findTestObject(‘myObject’))
@Vinh Nguyen said:
It should be like this:import org.openqa.selenium.WebDriver
import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.By
WebDriver driver = DriverFactory.getWebDriver()
eleCount = driver.findElements(By.xpath("//*[text()=‘Coach 1’])).size()
I’ve done exactly this but get the following error:
My code:
import org.openqa.selenium.WebDriver
import org.openqa.selenium.By
import com.kms.katalon.core.webui.driver.DriverFactory
WebDriver driver = DriverFactory.getWebDriver()
total_rows = driver.findElements(By.xpath('//*[@id="grid"]/table/tbody/tr')).size()
The error I get is:
Test Cases/Authentication Tests/finduser FAILED because (of) groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.comment() is applicable for argument types: (java.lang.Integer) values: [257]
Possible solutions: comment(java.lang.String), collect(), collect(groovy.lang.Closure), collect(java.util.Collection, groovy.lang.Closure)
So it seems to find the correct value - 257 is the count I need.
How do I return it correctly?
You have problem with “comment” not with “total_rows”. Try this: WebUI.comment(total_rows as String).
Hey Vinh_Nguyen, how can I get the XPath of a test object present in object repository?
import com.kms.katalon.core.testobject.SelectorMethod
String myXpath = YourTestObject.getSelectorCollection().get(SelectorMethod.XPATH)