No property for driver.find_element, any alternative?

def links = driver.find_elements(By.LINK_TEXT, 'Submit') not working (transferring the test case from python into katalon work there in selenium with python)

getting all the links with this with name Submit

groovy.lang.MissingPropertyException: No such property: driver for class: Script1615503258213

Any library to import ?

Accessible properties

Sorry, but do you want all the links or only the one indicated by the red “arrow”? If you want only the one, how about using the below style, which KS supports :

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.By as By
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement

WebDriver driver = DriverFactory.getWebDriver();
pLabel = driver.findElement(By.xpath('//a[text()="Submit"]'))

All link on page have same link name Submit

okay, then you will have to give more info to the path, such as:

pLabel = driver.findElement(By.xpath('//tr[3]/td/a[text()="Submit"]'));

or if you want to get it via the table and then cycle through it for your specific row:

'To locate table'
WebElement Table = driver.findElement(By.xpath("//table/tbody"));
'To locate rows of table it will Capture all the rows available in the table'
List<WebElement> rows_table = Table.findElements(By.tagName('tr'));
1 Like

there are 50 rows that is confirmed and printed on console. Need all the Submit links from that webtable under the columnname Request

All links under Column name Request

Properties for a

Trying with this Webtable script

WebDriver driver = DriverFactory.getWebDriver()
//String ExpectedValue = Submit

WebElement Table = driver.findElement(By.xpath("//table/tbody"))
List<WebElement> Rows = Table.findElements(By.tagName('tr'))
println('No. of rows: ' + Rows.size())

List<WebElement> links = Rows.findElements(By.linkText('Submit'))
table: for (int i = 0; i < Rows.size(); i++) {

def link = links.get(4).findElement(By.tagName('a'))

println link

table: break


DEBUG                 - 7: println("No. of rows: " + Rows.size())
No. of rows: 50
DEBUG                 - 8: links = Rows.findElements(By.linkText("Submit"))
ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/link FAILED.
groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.findElements() is applicable for argument types: (org.openqa.selenium.By$ByLinkText) values: [By.linkText: Submit]

all links xpath starts from /html/body/table/tbody/tr[1]/td[5]/a and last link is

One concern in your code is you have: table: break. This should be: break table;

Another concern is that findElements seems to be a property of WebElement, not List<WebElement>. So maybe go straight there from the table, such as:

WebElement Table = driver.findElement(By.xpath("//table/tbody"))
List<WebElement> links = Table.findElements(By.linkText('Submit'))

println('No. of rows: ' + links.size())