Groovy 我可以将表搜索中的值存储在变量中吗?

Groovy 我可以将表搜索中的值存储在变量中吗?,groovy,katalon-studio,groovy-console,katalon-recorder,java.lang.class,Groovy,Katalon Studio,Groovy Console,Katalon Recorder,Java.lang.class,我有以下代码: WebUI.openBrowser('') WebUI.navigateToUrl('https://www.texaslending.com/') WebUI.click(findTestObject('Page_TexasLending.com - When you think of m_ec7bcf/img_Simplify your search. Select your loan._410ce5')) WebUI.delay(1) WebUI.click(

我有以下代码:

 WebUI.openBrowser('')

 WebUI.navigateToUrl('https://www.texaslending.com/')

 WebUI.click(findTestObject('Page_TexasLending.com - When you think of m_ec7bcf/img_Simplify your search. Select your loan._410ce5'))

WebUI.delay(1)

WebUI.click(findTestObject('Page_Refinance Home  Current Mortgage Rates_4ab5ec/img_Blog_do-not-smush'))

WebUI.delay(1)

WebUI.setText(findTestObject('Page_Sales Funnel - TexasLending.com/input_What is your current loan balance_fie_eccf68'), 
    '653')

WebUI.click(findTestObject('Page_Sales Funnel - TexasLending.com/img_What is your current loan balance_vc_si_5c602b'))

WebUI.delay(1)

WebUI.click(findTestObject('Page_Sales Funnel - TexasLending.com/div_We currently do not loan in this area'))

WebUI.delay(1)

WebUI.setText(findTestObject('Page_Sales Funnel - TexasLending.com/input_Zipcode_zip'), '75065')

WebUI.delay(1)

WebUI.click(findTestObject('Page_Sales Funnel - TexasLending.com/img_We currently do not loan in this area.__d583fb'))

WebUI.delay(1)

WebUI.click(findTestObject('Page_Sales Funnel - TexasLending.com/img_How did you hear about us_vc_single_ima_7c4a04'))

WebUI.setText(findTestObject('Page_Sales Funnel - TexasLending.com/input_First Name_fname'), 'test')

WebUI.setText(findTestObject('Page_Sales Funnel - TexasLending.com/input_Last Name_lname'), 'test')
这里我得到了一个时间戳,每次输入不同的电子邮件


def address = CustomKeywords.'com.costea.EmailUtil.getMyAddress'() 

WebUI.setText(findTestObject('Page_Sales Funnel - TexasLending.com/input_Email Address_email'), address)

WebUI.setText(findTestObject('Page_Sales Funnel - TexasLending.com/input_Email Address_email'), address)

WebUI.delay(0)

WebUI.click(findTestObject('Page_Sales Funnel - TexasLending.com/input_Phone Number_field27977902'))

WebUI.setText(findTestObject('test2/Page_Sales Funnel - TexasLending.com/input_Phone Number_field27977902'), '1234567890')

WebUI.click(findTestObject('test2/Page_Sales Funnel - TexasLending.com/img_I agree to the Terms and Conditions and_928f25'))

WebUI.closeBrowser()

WebUI.delay(2)

WebUI.openBrowser('')

WebUI.maximizeWindow()

WebUI.navigateToUrl('https://lm.prod.velocify.com/Web/Login.aspx')

WebUI.setText(findTestObject('Object Repository/Page_LeadManager - Login/input_User Name_usernameTextBox'), '')

WebUI.setEncryptedText(findTestObject('Object Repository/Page_LeadManager - Login/input_Password_passwordTextBox'), '')

WebUI.click(findTestObject('Object Repository/Page_LeadManager - Login/input_Password is required._loginButton'))
def v = WebUI.getAttribute(findTestObject('Page_Sales Funnel - TexasLending.com/input_Email Address_email'),
        'value')
def result = WebUI.verifyEqual(v, address)
if (result) {
    WebUI.comment("Good! The address ${address} is what I expected")    
} else {
    WebUI.comment("Nein, die Adresse ${address} ist nicht das, was ich erwartet habe")
}
从这里,我想检查其他页面表格上方的特定电子邮件输入,我正在使用表格检查

String ExpectedValue = address;

WebDriver driver = DriverFactory.getWebDriver()

//Expected value from Table
WebElement Table = driver.findElement(By.xpath('//*[@id="leadtable"]'))

//To locate table
rows_table = Table.findElements(By.tagName('//th/td'))

// To locate rows of the table it will Capture all the rows available in the table
List<WebElement> rows_table = Table.findElements(By.tagName('th'))

// To calculate no of rows In table
int rows_count = rows_table.size()

// Loop will execute for all the rows of the table
Loop: 
for (int row = 0; row < rows_count; row++) {
    List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName('a'))

    int columns_count = Columns_row.size()

    println((('Number of cells In Row ' + row) + ' are ') + columns_count)

for (int column = 0; column < columns_count; column++) {
        String celltext = Columns_row.get(column).getText()

        
        println((((('Cell Value Of row number ' + row) + ' and column number ') + column) + ' Is ') + celltext)

        if (celltext == ExpectedValue) {
            println('Lead is present ' + Columns_row.get(2).getText())
        } else {
            println('Lead is not added')

            break
        }
    }
}
提前谢谢你

用这个为我工作:


WebDriver driver = DriverFactory.getWebDriver()

//Expected value from Table
WebElement Table = driver.findElement(By.xpath('//*[@id="leadtable"]'));

//To locate table
rows_table = Table.findElements(By.tagName('/tr/th'));

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

// To calculate no of rows In table
int rows_count = rows_table.size();
println("rows_count=${rows_count}");
// Loop will execute for all the rows of the table
Loop: 
for (int row = 0; row < rows_count; row++) {
    List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName('td'));

    int columns_count = Columns_row.size();

    println((('Number of cells In Row ' + row) + ' are ') + columns_count);
boolean found = false
for (int column = 0; column < columns_count; column++) {
//Here I add value 10 in the row.get()  
celltext = Columns_row.get(10).getText()

  println((((('Cell Value Of row number ' + row) + ' and column number ') + column) + ' Is ') + celltext)

  if (celltext == ExpectedValue) {
    found = true
    println('Lead is present ' + Columns_row.get(10).getText())
  } 
  else {
  println('Lead is not added')
    break Loop;
  }
}
}

WebDriver=DriverFactory.getWebDriver()
//表中的预期值
WebElement Table=driver.findElement(By.xpath('/*[@id=“leadtable”]');
//查找表
行\u table=table.findElements(按.tagName('/tr/th'));
//要定位表中的行,它将捕获表中所有可用的行
列表行\u table=table.findElements(按.tagName('tr'));
//计算表中行数的步骤
int rows\u count=rows\u table.size();
println(“rows\u count=${rows\u count}”);
//循环将对表的所有行执行
循环:
对于(int row=0;row